Zend Server Best Practices > Development > Configuring Zend Framework

Configuring Zend Framework

The following procedure describes how to configure Zend Server for IBMi to run Zend Framework projects in a development environment, using port-based virtual hosts. The advantage of port-based virtual hosts is in the ease of running several isolated applications on the same Web server. This overall solution allows developers working on a Zend Framework project in Zend Studio to immediately test any code changes locally.

Tip:

The following procedure uses instructions suitable for Zend Studio for Eclipse and the Apache bundled with Zend Server. A similar procedure with some modifications can apply for other IDEs and web servers.

 

 

Instructions on how to complete a procedure

To configure Zend Server for IBMi to run a Zend Framework application:

  1. Create a new Zend Framework project.
    If you have not already done so, create a new Zend Framework project using the New Zend Framework Wizard in Zend Studio for Eclipse.

  2. Define a virtual host on Zend Server for IBMi that will point to the new project's public directory:

    1. Find the full path to your project's public directory.
      In Zend Studio for Eclipse, go to the project browser and right-click on the public directory from the menu select Properties. The full path is listed in the Resource Tab's location field.

    2. Open your Apache configuration file (in most cases it will be httpd.conf and located in your Apache installation directory).
      Where is my Apache configuration file?

    3. Go to the end of the file and add the following section:

Listen 10089

<VirtualHost *:10089

    DocumentRoot "DOCUMENT_ROOT

    <Directory "DOCUMENT_ROOT">

        Order allow,deny

        Allow from all

    AllowOverride all

</Directory>

</VirtualHost>

  1. Replace "DOCUMENT_ROOT" with the full path to the public directory, enclosed in double quotes ("DOCUMENT_ROOT")
    Replace the port number with a unique port number dedicated to this Virtual Host. The port number (10089) has to be the same value for "Listen" and "VirtualHost".

  2. Zend Framework's MVC implementation makes use of the Front Controller pattern. You must therefore rewrite all incoming requests (except those for static resources, which your application need not handle) to a single script that will initialize the FrontController and route the request. If you're using mod_rewrite for the Apache web server, create the file <Project_Name>/public/.htaccess with the following contents:

# public/.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

Note:

Some web servers may ignore .htaccess files unless otherwise configured. Make sure that your web server is configured to read the .htaccess file in your public directory.

  1. Restart your Web server from the command line .

Your Zend Framework projects will now be accessible from a browser through: http://localhost:10089/ (the port number 10089 should be replaced with the unique port you dedicated to this virtual host).

Where is My Apache Configuration File?

Apache uses a main configuration file for all its settings, typically this file is called httpd.conf or apache2.conf. The location of this file varies depending on your installation:

 

Read Also

  Zend Framework    
  Working with Zend Framework    
  http://framework.zend.com    
 

http://framework.zend.com