Creating a new module
The core of the Zend Framework 2 library is modular and everything is based around a module based system. That's why we will explain this thoroughly in this recipe, so that we can use it in its best way possible.
Getting ready
We will be using the Zend Framework skeleton application for creating new modules. As a reminder, the Zend Framework 2 skeleton application can be found at https://github.com/zendframework/ZendSkeletonApplication.
How to do it…
Creating a new module is like starting a new drawing, it is exciting and fun to create a new functionality, but there are always rules we need to obey. In this recipe we will discuss what the rules are for setting up a new module.
Creating the Module.php
We can start off with just a simple class file (that is, /module/Sample/Module.php
) in the right namespace (Sample
) with nothing in it, which is basically the only requirement there is for the module.
<?php namespace Sample; class Module {}
We can add the following method...