Creating and Running a Zend Framework Example Project

The purpose of the Zend Framework Example Project is to demonstrate the capabilities and best practices of working with the Zend Framework.

Zend Framework is a high quality open source framework for developing Web Applications and Web Services with PHP. The Zend Framework Example Project is a small demo application that shows how Zend Framework can be leveraged in order to streamline writing code, by decreasing development time (through using prewritten modules) and demonstrating how to implement best practices in organizing your project.

Once the Example Project has been created, you will be able to navigate through the tree in PHP Explorer and see the different components of the project.

This project is a small application that contains employee information, accessed through a login screen.

 

The Zend Framework Example provides a model called MVC (Model-View-Controller) for programming using the Framework. With this model, applications are divided into three parts to assist in making the development process more efficient.

The components are:

  • Controller - includes all code that handles the logic.

  • Model - contains data access commands to the raw data.

  • View - contains the application's front end (User Interface).

Additional information about programming with the Zend Framework can be found in the official Zend Framework Manual at: https://framework.zend.com

For more information about the MVC method see http://en.wikipedia.org/wiki/Model-view-controller.

Creating the Zend Framework Example Project

The following procedure describes how to create a Zend Framework example project.

 

 

Instructions on how to complete a procedure

To create a Zend Framework Example Project:

  1. Go to File | New | Example | Zend Framework Example Project.
    The New Zend Framework Project dialog is displayed.

  1. Enter a name for your example project.

  2. You have two options for the contents of your Zend Framework Example Project:

  • Create new project in workspace - Creates the project in your current workspace.

  • Create project at existing location - Creates the project from an existing location outside of your workspace.

You may choose your location by writing it in the "Directory" text field, or by clicking Browse.

  1. Click Finish
    An example project will be created and displayed in the PHP Explorer view.

You can navigate through the application source files to learn more about the source behind the application.

Running the Zend Framework Example Project

Note:

The Zend Framework Example project must be placed on a server configured to run Zend Framework. See ' Setting Up Your Server Environment ', below,  to learn more about configuring your server to enable Zend Framework project execution.

 

 

Instructions on how to complete a procedure

To run your Zend Framework Example Project:

  1. Copy the Zend Framework Example project to your server's document root.
    Ensure the name of the project is 'ZendFrameworkExampleProject'.

  2. In PHP Explorer view, right-click "index.php" (located in the "www" folder of the ZendFrameworkExample project) and select Run As | PHP Web Page.
    The Run PHP Web Page dialog is displayed.

  3. Ensure the URL selected points to the location of the index.php file on your server (by default, this will be http://localhost/ZendFrameworkExampleProject/www/index.php).

  4. Click OK.

  5. A Path Mapping dialog might appear asking you to select the local location of your Front Controller.
    Select the Zend\Controller\Front.php file in your FRAMEWORK_HOME directory and click OK.

  1. The Demo Application will appear in the Internal Browser.

  1. To login to the application, enter any user name and use the same name for the password.

  2. You can now navigate through the application.

 

Running the Zend Framework Example Project

The following procedure describes how to run the Zend Framework example project. In order to run your Zend Framework Example Project, you must first create one. For more information see Creating the Zend Framework Example Project.

Note:

You must have an established connection with a server to run the Zend Framework Example project. For more information see Defining Zend Server in Zend Studio.

 

 

Instructions on how to complete a procedure

To run the Zend Framework example project:

  1. Expand your Zend Framework Example project in the PHP Explorer View.
    The project's sub-folders will be exposed.

  2. Expand the sub-folder called public and right click on the sub-file index.php. From the right click menu select Run As | PHP Web Application.
    The "Run PHP Web Page" dialog will open.
    If the dialog does not open you will need to add this directory to the build path by right-clicking on the Public folder and selecting Build Path | Include.
    You do not need to make any changes in order to run the example project.  

  3. Click OK.

Your project Web page opens.

Setting Up Your Server Environment

Prerequisites:

  • Apache 2.2 or later*

  • PHP 5*

  • Zend Framework* (at least 0.93beta)

* These components can be installed together by installing Zend Core version 2.5. However, if you are using an older version of Zend Core, you will need to download the latest Zend Framework files from https://framework.zend.com/ .

 

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

 

 

Instructions on how to complete a procedure

To run the Example Project, first set up your server environment by following these steps:

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

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

  2. If you do not have the Zend Framework files already installed on your machine, install Zend Core 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 Core make sure you install the following:

  1. PHP 5

  2. Apache 2

  3. Zend Framework files (at least 0.93beta, downloadable from https://framework.zend.com/ ).

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

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

  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 Core, this can be found under the 'session-Session Management' extension in Configuration | Extensions.

  3. PHP Short Tags are enabled.
    This is configured in the short_open_tag directive.
    In Zend Core, this cannot be disabled.

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

  1. Restart your Web server after applying changes.

You can now run your Zend Framework Example project following the instructions under ' Running the Zend Framework Example Project ', above.