Create Your Project

In order to create your project, you must first download and extract Zend Framework.

Download and Extract Zend Framework

Download the latest version of Zend Framework and extract the contents; make a note of where you have done so.
Optionally, you can add the path to the library/ subdirectory of the archive to your php.ini's include_path setting.
That's it! Zend Framework is now installed and ready to use.

Create Your Project

zf Command Line Tool
In your Zend Framework installation is a bin/ subdirectory, containing the scripts zf.sh and zf.bat for Unix-based and Windows-based users, respectively. Make a note of the absolute path to this script.
Wherever you see references to zf.sh or zf.bat, please substitute the absolute path to the script. On unix-like systems, you may want to use your shell's alias functionality: alias zf.sh=path/to/ZendFramework/bin/zf.sh.
If you have problems setting up the zf command-line tool, please refer to the manual.
Open a terminal (in Windows, Start -> Run, and then use "cmd"). Navigate to a directory where you would like to start a project. Then, use the path to the appropriate script, and execute one of the following:

% zf.sh create project quickstart

C:> zf.bat create project quickstart
Running this command will create your basic site structure, including your initial controllers and views. The tree looks like the following:
quickstart
|-- application
|   |-- Bootstrap.php
|   |-- configs
|   |   `-- application.ini
|   |-- controllers
|   |   |-- ErrorController.php
|   |   `-- IndexController.php
|   |-- models
|   `-- views
|       |-- helpers
|       `-- scripts
|           |-- error
|           |   `-- error.phtml
|           `-- index
|               `-- index.phtml
|-- library
|-- 
|   `-- index.php
`-- tests
    |-- application
    |   `-- bootstrap.php
    |-- library
    |   `-- bootstrap.php
    `-- phpunit.xml
At this point, if you haven't added Zend Framework to your include_path, we recommend either copying or symlinking it into your library/ directory. In either case, you'll want to either recursively copy or symlink the library/Zend/ directory of your Zend Framework installation into the library/ directory of your project. On unix-like systems, that would look like one of the following:

% cd library; ln -s path/to/ZendFramework/library/Zend .

% cd library; cp -r path/to/ZendFramework/library/Zend .
On Windows systems, it may be easiest to do this from the Explorer.
Now that the project is created, the main artifacts to begin understanding are the bootstrap, configuration, action controllers, and views.
The Bootstrap
Your Bootstrap class defines what resources and components to initialize. By default, Zend Framework's Front Controller is intialized, and it uses the application/controllers/ as the default directory in which to look for action controllers (more on that later). The class looks like the following:

 Bootstrap  Zend_Application_Bootstrap_Bootstrap
{
}
As you can see, not much is necessary to begin with.
Configuration
While Zend Framework is itself configurationless, you often need to configure your application. The default configuration is placed in application/configs/application.ini, and contains some basic directives for setting your PHP environment (for instance, turning error reporting on and off), indicating the path to your bootstrap class (as well as its class name), and the path to your action controllers. It looks as follows:
; application/configs/application.ini
[production]
phpSettings.display_startup_errors = 
phpSettings.display_errors = 
includePaths.library = APPLICATION_PATH 
bootstrap.path = APPLICATION_PATH 
bootstrap. = 
resources.frontController.controllerDirectory = APPLICATION_PATH 
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 
phpSettings.display_errors = 
[development : production]
phpSettings.display_startup_errors = 
phpSettings.display_errors = 
Several things about this file should be noted. First, when using INI-style configuration, you can reference constants directly and expand them; APPLICATION_PATH is actually a constant. Additionally note that there are several sections defined: production, staging, testing, and development. The latter three inherit settings from the "production" environment. This is a useful way to organize configuration to ensure that appropriate settings are available in each stage of application development.
Action Controllers
Your application's action controllers contain your application workflow, and do the work of mapping your requests to the appropriate models and views.
An action controller should have one or more methods ending in "Action"; these methods may then be requested via the web. By default, Zend Framework URLs follow the schema /controller/action, where "controller" maps to the action controller name (minus the "Controller" suffix) and "action" maps to an action method (minus the "Action" suffix).
Typically, you always need an IndexController, which is a fallback controller and which also serves the home page of the site, and an ErrorController, which is used to indicate things such as HTTP 404 errors (controller or action not found) and HTTP 500 errors (application errors).
The default IndexController is as follows:

 IndexController  Zend_Controller_Action
{
      init()
    {
        
    }
      indexAction()
    {
        
    }
}
And the default ErrorController is as follows:

 ErrorController  Zend_Controller_Action
{
      errorAction()
    {
        $errors = $this->_getParam();
        
         ($errors->type) { 
             Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
             Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
        
                
                $this->getResponse()->setHttpResponseCode();
                $this->view->message = ;
                ;
            :
                
                $this->getResponse()->setHttpResponseCode();
                $this->view->message = ;
                ;
        }
        
        $this->view-> = $errors->;
        $this->view->request   = $errors->request;
    }
}
You'll note that (1) the IndexController contains no real code, and (2) the ErrorController makes reference to a "view" property. That leads nicely into our next subject.
Views
Views in Zend Framework are written in plain old PHP. View scripts are placed in application/views/scripts/, where they are further categorized using the controller names. In our case, we have an IndexController and an ErrorController, and thus we have corrsponding index/ and error/ subdirectories within our view scripts directory. Within these subdirectories, you will then find and create view scripts that correspond to each controller action exposed; in the default case, we thus have the view scripts index/index.phtml and error/error.phtml.
View scripts may contain any markup you want, and use the <?php opening tag and ?> closing tag to insert PHP directives.
The following is what we install by default for the index/index.phtml view script:
<!-- application/views/scripts/index/index.phtml -->
<style>
    
    a:link,
    a:visited
    {
        color: #0398CA;
    }
    span#zf-name
    {
        color: #91BE3F;
    }
    div#welcome
    {
        color: #FFFFFF;
        background-p_w_picpath: url(http://framework.zend.com/p_w_picpaths/bkg_header.jpg);
        width:  600px;
        height: 400px;
        border: 2px solid #444444;
        overflow: hidden;
        text-align: center;
    }
    
    div#more-information
    {
        background-p_w_picpath: url(http://framework.zend.com/p_w_picpaths/bkg_body-bottom.gif);
        height: 100%;
    }
</style>
<div id="welcome">
    <h1>Welcome to the <span id="zf-name">Zend Framework!</span><h1 />
    <h3>This is your project's main page<h3 />
    <div id="more-information">
        <p>
            <img src="http://framework.zend.com/p_w_picpaths/PoweredBy_ZF_4LightBG.png" />
        </p>
        <p>
            Helpful Links: <br />
            <a href="http://framework.zend.com/">Zend Framework Website</a> |
            <a href="http://framework.zend.com/manual/en/">Zend Framework 
                Manual</a>
        </p>
    </div>
</div>
The error/error.phtml view script is slightly more interesting as it uses some PHP conditionals:
<!-- application/views/scripts/error/error.phtml -->
<!DOCTYPE html  ; 
    http:
<head>  
  <meta http-equiv= content= /> 
  <title>Zend Framework  Application</title> 
</head> 
<body> 
  <h1>An error occurred</h1> 
  <h2><?php  $this->message ?></h2> 
  <?php  ( == $this->env): ?> 
  
  <h3> information:</h3> 
  <p> 
      <b>Message:</b> <?php  $this->->getMessage() ?> 
  </p> 
  <h3>Stack trace:</h3> 
  <pre><?php  $this->->getTraceAsString() ?> 
  </pre> 
  <h3>Request Parameters:</h3> 
  <pre><?php  var_export($this->request->getParams(), ) ?> 
  </pre> 
  <?php  ?>
  
</body> 
</html>

Checkpoint

At this point, you should be able to fire up your initial Zend Framework application. Create a virtual host in your web server, and point its document root to your application's public/ subdirectory. Make sure your host's name is in your DNS or hosts file, and then point your browser to it. You should be able to see a welcome page at this point.