jump to navigation

Zend Framework : Customizing the Directory Structure April 13, 2011

Posted by Tournas Dimitrios in Zend Framework v1.10.

By default , Zend Framework expects a standard directory structure , from Zend Framework 1.8 and onwards , the proccess of creating a project is simplified with the help of an Zend command line utility  ” zf ” ( zf  create  project  nameOfProject ) . This layout contains three main folders :

  • application : Contains the controllers , models and views , each in a separed folder so that the application is good organized .
  • public : Contains the defauld index page and all publicly available resources ( css , media-files , javascripts etc ..)
  • library (contains custom library files and is some cases the Zend Framework itself )

Picture of the directory structure :

This default directory structure must be maintained , to have the application run smoothly . Sometimes breaking from such a directory structure is necessary when storing the views , however . Fortunately the Zend_View can easily configured to adapt the new structure .

Each controller contains one or more actions , where each action is associated (mapped) with a view script . Let’s now pretend that we need to render a different view script from a specific controller action . The code would be :

//Inside the action function of the conroller
$view->setScriptPath("absolute path to the new view dir");

The setScriptPath() method forces Zend_view to change the default directory it normally uses to locate the views to the one specified using the method . The only requirement is that each controller must have its own folder within this new base directory .


1. Gayle Johe - April 24, 2011

Incredible information provided, thank you!

2. Cecile Hoare - April 25, 2011

Thanks for another great article. Where else could anybody get that kind of info in such an ideal way of writing? I have a presentation next week, and I am on the look for such information.

3. Elise Marthe - May 7, 2011

Hey very cool blog!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds also…I am happy to find a lot of useful information here in the post, we need work out more strategies in this regard, thanks for sharing. . . . . .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s