Over the past several years I’ve created a number of Zend Framework applications. For my projects I’ve found that a “module” based directory structure works best. The following describes how I setup my applications using a modular based directory structure.
Step 1: Download
http://framework.zend.com/download/latest
Step 2: Install
Follow the instructions in the “Create Your Project” section of Zend Framework’s Quick Start guide. Only follow the instructions to the “Checkpoint” (do not move on to the next step in the guide).
http://framework.zend.com/manual/en/learning.quickstart.create-project.html
Step 3: Create default module
zf create module default |
Note: The exact command I used is:
~/Downloads/ZendFramework-1.11.4-minimal/bin/zf.sh create module default
Step 4: Edit the application.ini configuration file
(application/configs/application.ini)
1) Remove the following line:
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" |
2) Change the following line:
resources.frontController.params.prefixDefaultModule = "1" |
-to-
resources.frontController.params.prefixDefaultModule = false |
3) Add the following to the bottom of the [production] section:
resources.frontController.defaultmodule = "default" resources.modules[] = |
4) Under this line:
appnamespace = "Application" |
…add these lines:
autoloadernamespaces[] = "Zend" autoloadernamespaces[] = "App" |
Step 5: Create our “App” directory
This is where I like to put all of my application’s library code/classes. If your going to use a different name for your application’s library code make sure to adjust the ‘autoloadernamespaces[] = “App”‘ line from the previous step.
mkdir library/App |
Step 6: Copy Files and Clean up
Copy all the files in (application/views) to (application/modules/default/views) and clean up
cp -R application/views/* application/modules/default/views rm -fr application/views |
Copy all the files in (application/controllers) to (application/modules/default/controllers) and clean up
cp -R application/controllers/* application/modules/default/controllers rm -fr application/controllers |
Remove the leftover “models” folder
rm -fr application/models |
Finished!
At this point you should be able to browse to your project and see the “Welcome to the Zend Framework!” welcome page.
Environment
Ubuntu 10.10
PHP 5.3.3
Zend Framework 1.11.4
References
Zend Framework Quick Start
Using a Conventional Modular Directory Structure