When we try to generate the project by Zend_Tool by command line like this:
We get a standard structure which is recommended by Zend Framework:
It works very fine as “one” website project. But how about if we want to create multiple websites without rewriting too many code?
The main idea is to share as much as possible the libraries meanwhile keeping independence of each website, especially the designs/templates/publics.
Here is one simple way which makes the minimal modifications and satisfy our needs:
(1) Move the folder “library” out of the project.
(2) Modify /public/index.php as below to make sure the library/ is in include paths:
(3) Modify /application/config/application.ini :
includePaths.library = APPLICATION_PATH "/../../library"
Assume that we have project1, project2 and project3, all applied the same treatment. And finally the websites could like this:
In the picture above, assume that our global namespace is “Projlib”. We have a model class Projlib/Model/Foo.php
Then we can just put this configuration inside application/configs/application.ini to make it autoloaded:
autoloadernamespaces.global = "Projlib_"
And that’s all! Enjoy it.