In the User Demo sample, we create a new module called User and add all functionality related to user management and authentication to that module. If you are new to the concept of modules, refer to chapter Creating a New Module.
The User module will have very few dependencies on other modules of the website. The idea behind the User module is to give you a reusable unit that you can use in your own web application, without any changes or with some modifications.
Ideally, you will be able to use the User module in your own website without any changes. But, in real-life websites, you'll probably have to add some fields to the
usertable, modify the user creation workflow, or modify the access filtering algorithm. It this case, you'll have to customize the code of the User module to feet your needs.
The User module will have the following structure (see figure 16.1 below):
Let's briefly describe what classes we will have inside module's directory.
We will have two controllers:
There will be one Doctrine entity:
We will have four forms used to collect data:
We will have several services:
Most controllers and services will be instantiated with factories. You can find the factory classes under the Factory subdirectories.
Inside the view directory, we will have several view templates which will render HTML markup of the web pages present in the user interface exposed by our module.
As usual, inside the config directory, we will have the module.config.php file that will contain routes and registration for our controllers and services. It will also contain the access_filter key defining which pages will be accessible to an unauthenticated user (this key will be read by AuthManager service).
As you can see, the User module is a typical ZF3 module with the structure conforming to the MVC pattern.