Make your Laravel 6.2 application modular.
Modular creates and manages modules for Laravel 6.2. The created modules behave like any package designed for Laravel. With few benefits:
- Autoloaded modules
- Auto registration of middlewares, langs, views and routes (web only)
- Auto-merged configuration file
Create a new Laravel 6.2 project.
$ composer create-project --prefer-dist laravel/laravel your_project
Install the latest version with
$ composer require jsagot/laravel-modular
...
/*
* Package Service Providers...
*/
Navel\Laravel\Modular\Providers\ModularServiceProvider::class,
...
$ php artisan vendor:publish --provider="Navel\Laravel\Modular\Providers\ModularServiceProvider" --tag="modular.config"
in config/modular.php
return [
'active' => true,
'path' => 'modules',
'namespace' => 'Modules\\',
];
Modules directory should be at the root of your Laravel project.
ex:
- your_project/
- app/
- bootstrap/
- ...
- modules/
$ php artisan module:make your_module_name
The default option creates modules in the 'modules/' directory. This will be customizable in future version.
your_module_name should be as simple as possible (DO NOT USE "-_." or any special character. CamelCase works).
$ php artisan modular:demo
You can then access to http://localhost/demo?demo=demo to see the demo module in action. (See code and comments)