Using ZF Tool to Create a Modular Zend Framework Application

Apr 29


This is just a quick guide on creating a modular application structure in the Zend Framework using the Zend Framework Tool (more or less).

The Process

First move to your directory.

cd /var/www/

Now create the project

zf create project MyApp
cd MyApp

Now that we have a functioning app. The next step is to turn it into a modular application. First we remove the controller and view directories then we create our first module with its controller, action, and view.

rm -rf application/controllers/
rm -rf application/views/
rm -rf application/models/
zf create module default
zf create controller Index 1 default

Now that we have our default controller with a index controller and index view, were almost there. The system isn’t yet setup to use the modules so the last thing we need to do is edit the application configuration file. In the application config you will make the following change

; Remove this line from your current application.ini
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
; Add this line in its place
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"


This is the process that I currently use. I’m sure there is a much easier solution to this but I haven’t found it. Please let me know in comments if you know of a better way.


  1. Great introduction. Thanks!

  2. Sascha /

    Straightforward and it works – in contrast to examples from the foggy zend documentation. Thanks for posting

  3. Thanks Christian, great works, is exactly and very simply and easy.


  4. Any idea how to remove the module name form the url. Using modules makes my url get cluttered. using this scheme /module/controller/action is kinda long. BTW thanks for the post very useful

  5. @Edgar I replied via email with the code you will need, but this issue is fixed in your applications router. All the information you should need can be found in the Zend Framework docs at


  1. complex zf setup, how to do this. - [...] problem with Zend Tool is that it's difficult to use with a modular application: Using ZF Tool to Create ...

Leave a Reply