Documentation

Module Manager

The Module Manager is responsible for iterating over an array of module names and triggering a sequence of instantiation of module classes, initialization, and merge configuration.

Module

By default, one module is provided with the JiNexus Framework, named "Application". It provides a controller to handle the "home" page of the application, the layout template, and templates for 404 and error pages, and its own configuration.

Module is loaded through the help of Module Manager. You can create another module to separate other controllers and layout templates.

Create a new Module

Lets create a new module name "Blog". Below is the updated Application Structure of my project:

                    
    application_root/
        config/
            application.config.php
            modules.config.php
        data/
        module/
            Application/
            Blog/
                config/
                    module.config.php
                src/
                    Controller/
                    Module.php
                view
        public/
            asset/
            .htaccess
            index.php
        vendor/
                    
                

Next is you have to modify the Module.php and add the following methods. Your Module.php should look like this:

    
    namespace Application;

    use JiNexus\ModuleManager\ModuleManager\AbstractModule;

    class Module extends AbstractModule
    {
        /**
         * @return mixed
         */
        public function getConfig()
        {
            return include __DIR__ . '/../config/module.config.php';
        }
    }
    
                

Next is we have to map our new module using PSR-4 auto loading. Your composer.json should look like this:

    
    "autoload": {
        "psr-4": {
            "Application\\": "module/Application/src/",
            "Blog\\": "module/Blog/src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Application\\": "module/Application/test/",
            "Blog\\": "module/Blog/test/"
        }
    }
    
                

Lastly is we have to enable our new module by adding it to our config/modules.config.php.

Your modules.config.php should look like this:

    
    /**
     * List of enabled modules for this application.
     * 
     * This should be an array of module namespaces used in the application.
     */
    return [
        'Application',
        'Blog',
    ];