Modules
Last updated
Was this helpful?
Last updated
Was this helpful?
The doMynation framework encourages . Modules are the pillars of your app, and each of them represent a logical group of related concepts. For instance, in a large system, you could have dozens of modules, each of which specializing in one area in particular (e.g. accounting, sales, customer service, etc).
Every application using the doMynation framework must have at least one module. A module is where you register the following 4 foundational components:
Dependencies
Routes
Templates
Event listeners
All module must extend the Domynation\Core\Module
class and implement the following methods:
The registerContainerDefinitions
method is used to define and register your dependencies to be used via throughout your app. Each definition is a key-value pair where the key is a class name, and the value is a closure that constructs and returns an instance of said class.
Note: Each closure is , meaning you can inject previously-registered dependencies into them to facilitate the creation of complex objects.
The registerRoutes
method is used to define your routes. See the section for an in-depth explanation on how to create routes.
The registerViews
method is where you configure your templates for a given module. See the section for more details.
The registerListeners
method is used to register listeners for particular events. See the section for more details.
Each module can optionally define a boot()
method used to boot the module. This method is , which means you can pull all the necessary dependencies to boot your module.