A free and open-source book on Zend Framework for beginners


14.1. When to Create a New Module?

A module is an autonomous and reusable unit of your application. By default your application has the single Application module. And it is normal to put your models, views and controllers in this module, especially in a simple website.

A module can contain models, views, controllers and assets. Module classes typically live in a separate namespace (the same as module name). Module has its own configuration file where you can register routes, controllers, controller plugins, services, view helpers and so on.

You may need to create a new module when any of the following is true:

In any case, real life is complex, and you should be guided by the intuition when it seems that it is necessary to create a new module. If you think that separating a functionality into a module gives you some significant benefits, create the module.

At the same time, you should not create a huge number of almost empty modules, it is better to combine related functionality in a single module.


Top