I'm looking for a step-by-step explanation on how to go from the normal folder structure on the left where the application
folder contains models,views,controllers
, to the module-based folder structure on the right where application
contains a modules
folder which contains the individual modules with their own models,views,controllers
.
I say "conversion" because I don't think zend lets us create projects using the module architecture from the start, but if it did, that would be swell and would remove the need to make these folder structure changes manually.
Here's my experience so far
When I create a module
zf create module product
, the modules folder is generated and a folderproduct
is generated inside it and theviews,controllers,models
for that module are also generated.But I also need to move the main
views,controllers,models
to amodules/default
folder of their own. If I create that folder manually and move the mainviews,models,controllers
there, I get a bug when trying to add new controllers to thatdefault
module. The bug is that it re-generates the main (now missing)views,controllers,models
inapplication
and inserts that new controller inapplication/controllers/newcont
because it doesn't recognize that the default controllers folder has been moved manually toapplication/modules/default/controllers/
.So my solution to that has been to
zf create module default
then copy the mainviews,models,controllers
there. It ends up looking the same but somehow thezf create module
method makes a difference. When I do it this way, new controllers get added correctly intoapplication/modules/default/controllers
and notapplication/controllers
Half the problem solved. But when I try to view the application, I don't see anything from index/index
view. I don't get any errors either, but I see nothing. I suspect that it's because the application doesn't know that the index/index
view has moved.
- This used to be located at
application/views/scripts/index/index.phtml
- but is now located at
application/modules/default/views/scripts/index/index.phtml
I'm guessing I need to make changes to application.ini or to bootstrap.php or some other location. So what exactly are the steps to get this thing done smoothly and get it working? I'm using the latest ZF 1.10.8. Please start from create a new zend project so there's no confusion on the exact steps.