arikod/module

description

Maintainers

Details

github.com/arikod/module

Source

Issues

Installs: 15

Dependents: 1

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 4

Open Issues: 0

pkg:composer/arikod/module

v1.3 2021-10-09 10:40 UTC

This package is auto-updated.

Last update: 2026-01-09 21:00:31 UTC


README

Todo List

ModuleFacade

Install

To install through Composer, by run the following command:

composer require arikod/module

The package will automatically register a service provider and alias.

Optionally, publish the package's configuration file by running:

php artisan vendor:publish --provider="Arikod\Module\ModuleServiceProvider"

Register module

Create registration.php right next to composer.json

<?php

use Arikod\Module\ModuleRegistrar;

ModuleRegistrar::register(
    'Arikod_TestModule', // --> ModuleName
    \Arikod\TestModule\TestModuleServiceProvider::class // ServiceProvider
);

Enable / Disable Module

config/arikod.php

return [
    'modules' => [
        'Arikod_TestModule' => 1, // Enabled,
        'Arikod_ModuleAA' => 0    // Disabled
        // Arikod_ModuleBB // Disabled
    ],

    'glob' => [
        'lib/*/*/registration.php',
        'vendor/*/*/registration.php'
    ],
];

Usage

<?php

namespace App\Http\Controllers;

use Arikod\Module\FullModuleList;
use Arikod\Module\ModuleList;

class ModuleController extends Controller
{
    /**
     * @var ModuleList
     */
    protected $moduleList;

    /**
     * @var FullModuleList
     */
    protected $fullModuleList;

    public function __construct(ModuleList $moduleList, FullModuleList $fullModuleList)
    {
        $this->moduleList = $moduleList;
        $this->fullModuleList = $fullModuleList;
    }

    public function index()
    {
        // All Modules
        $fullModuleList = $this->fullModuleList;
        echo '<pre>',print_r($fullModuleList->getAll()),'</pre>';
        echo '<pre>',print_r($fullModuleList->getNames()),'</pre>';

        // Just Enabled Modules [config.php]
        $moduleList = $this->moduleList;
        echo '<pre>',print_r($moduleList->getAll()),'</pre>';
        echo '<pre>',print_r($moduleList->getNames()),'</pre>';
    }
}

Commands

php artisan module:status
php artisan module:status Arikod_TestModule
php artisan module:status Arikod_ModuleA Arikod_ModuleB
php artisan module:enable --all
php artisan module:enable Module_AA Module_BB

php artisan module:disable --all
php artisan module:disable Module_AA Module_BB

TestModule

To install through Composer, by run the following command:

composer require arikod/test-module

Credits

License

The MIT License (MIT). Please see License File for more information.