I’ve been trying to move some old code into separate modules for easier use later on. I installed zend framework and zend tool and created a new project:
zf create project myproject
Adding a new module is easy as pie:
zf create module mymodule
This creates the /application/modules/mymodule folder with complete MVC structure inside (controllers, models and views folders).
My module was not working so after a bit of looking around i’ve found Akrabat’s post that some light on the subject. You have to add to /application/configs.ini the following inside the [production] section:
# enabling modules resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules = ""
Good, now we should have a working module, except we don’t have any controllers. Trying to create a controller proved a bit tricky as zf tool would not pleace them in the right place, inside the modules/mymodule/controllers but in the default /application/controllers. The same applies for actions. With a bit of help from TheAshMan on #zftalk i found the right answer:
# create controller Photos_IndexController at /application/modules/controllers/Photos_IndexController.php zf create controller Photos_Index 1 mymodule # create the action view inside the Photos_IndexController zf create action view Photos_Index 1 mymodule
Hope this helps someone as it took me a few hours to figure it out 🙂