User Guide > Tasks > Developing with Zend Framework > Running and Debugging Zend Framework Projects

Running and Debugging Zend Framework Projects

In order to run and debug Zend Framework projects on your server, you will need to set up your server to be able to execute Zend Framework applications.

Setting Up Your Server Environment

Prerequisites:

* These components can be installed together by installing Zend Server.

 

The following instructions will guide you through the process of setting up your Zend Server in order to be able to run Zend Framework-based applications.

Note:

Zend Server is the recommended environment but Zend Framework projects can be run on other servers. Different configuration information might apply.

Setting up Your Server to Run/Debug Zend Framework Projects

 

 

Instructions on how to complete a procedure

To set up your server in order to run/debug Zend Framework Projects:

  1. If you do not have a server running a PHP distribution already installed, you can install Zend Server (downloadable from http://www.zend.com/en/products/server).
    Ensure you install with the following settings:

  1. If you do not have a Web server, install the Apache bundled with Zend Server.

  2. If you do not have the Zend Framework files already installed on your machine, install Zend Server in 'Complete' mode, or ensure that Zend Framework is selected in the list of additional components in 'Custom' mode.

  1. If you choose not to install Zend Server make sure you install the following:

  1. PHP 5

  2. Apache 2

  3. Zend Framework files (downloadable from https://framework.zend.com/).

  1. Make sure your php.ini settings are properly configured as follows: (These can be configured through Zend Server or by manually configuring your php.ini file).

Note:

If you are using Zend Server , these settings should be configured by default.

  1. Your include path is pointing to your Zend Framework library (e.g. .;C:\Program Files\Zend\ZendServer\share\ZendFramework\library).
    This is configured in the 'include_path' directive.
    In Zend Server, this directive can be found under the 'Paths and Directories' category in Server Setup | Directives.

  2. The session settings are configured to save path points to a temporary directory writable by the Web server (e.g."C:/temp" on Windows or "/tmp" on UNIX / Linux.)
    This is configured in the  'session.save_path' directive.
    In Zend Server, this directive can be found under the 'session' category in Server Setup | Directives.

  3. PHP Short Tags are enabled.
    This is configured in the short_open_tag directive.
    In Zend Server, this directive is on by default. It can be found under the 'Language Options' category in Server Setup | Directives.

  4. If you want to display errors, set your display error setting to on.
    This is configured in the display_errors directive.
    In Zend Server, this can found under the 'Error Handling and Logging' category in Server Setup | Directives.

  1. Restart your Web server after applying changes.

Once you copy your Zend Framework project files to the server you will be able to run and debug the project as you would a normal PHP project.

Configuring Zend Server to Run a Zend Framework Application

 

 

Instructions on how to complete a procedure

To configure Zend Server to run a Zend Framework application:

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

  1. Find the full path to your project's public directory.
    This is listed in the location field in the project's properties. To see it, in PHP Explorer view right-click the public directory and select Properties | Resources.

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

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

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 /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 (windows user can use the Apache Monitor tool).

 

Once you copy your Zend Framework project files to the server you will be able to run and debug the project as you would a normal PHP project.

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:

 

 

Related Links:
Creating Zend Framework Projects

Using the Debugger

Zend Framework Integration

Developing with Zend Framework

Creating Zend Framework Elements

Creating and Running a Zend Framework Example Project

 

 

©1999-2013 Zend Technologies LTD. All rights reserved.