teksite/module

a package to create modules for a laravel project

2.0.1 2025-05-05 07:18 UTC

This package is auto-updated.

Last update: 2025-06-05 07:26:18 UTC


README

About

This package has been developed to enable modularity in Laravel. All its commands are similar to Laravel native commands, with the difference that you need to prepend module: to the commands. Additionally, the name of the created file and the target module should be specified at the beginning of the command, followed by the arguments and options.

By default, teksite/lareon make a directories in the root of the application "Lareon/Modules" and generate small version of laravel directories and files, so you can deal with them as you do with Laravel

example

module:make-controller <ControllerName> <ModuleName> <--option>

Author

Sina Zangiband

Contact

Installation

Laravel package
11.0 ^1.0

Step 1: Install via Composer

Run the following command in your CLI:

composer require teksite\module

wikimedia/composer-merge-plugin

if you face to Do you trust "wikimedia/composer-merge-plugin" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] press y and enter. this package is used to recognize and merge composer.json files of modules.

Step 2: Register the Service Provider

Note: This step is not required for newer versions of Laravel (5.x and above) but in case:.

Laravel 10 and 11

Add the following line to the bootstrap/providers file:

Teksite\Module\ModuleServiceProvider::class,

Laravel 5.x and earlier

If you are using Laravel 5.x or earlier, register the service provider in the config/app.php file under the providers array:

'providers' => [
    // Other Service Providers
    Teksite\Module\ModuleServiceProvider::class,
];

Step 3: publish Service Provider (optional)

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

php artisan vendor:publish --provider="teksite\module\ModuleServiceProvider"
php artisan vendor:publish --provider="teksite\module\ModulesManagerServiceProvider"
php artisan vendor:publish --provider="teksite\module\RoutesManagerServiceProvider"

Step 4: add to Composer.json

By default, modules classes are not loaded automatically. You can autoload your modules by adding below codes:

"extra": {
    "laravel": {
        "dont-discover": []
    },
    "merge-plugin": {
        "include": [
            "Lareon/Modules/*/composer.json"
        ]
    }
},

Step 6: publish Service Provider (optional)

Tip: do not forget: composer dump-autoload .

How to work with the package

make a module

php artisan module:make Example

make a model in a module

php artisan module:make-model <name> <module> <--options>

make a controller in a module

php artisan module:make-controller <name> <module> <--options>

all commands of this package is same as Laravel with their options.

Change module priority

To change priority of loading modules you can change the order of modules in the config/modules.

Credits

License

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

Feel free to reach out if you have any questions or need assistance with this package!