Package Data | |
---|---|
Maintainer Username: | megaads-vn |
Maintainer Contact: | info@megaads.vn (megaads-vn) |
Package Create Date: | 2019-09-25 |
Package Last Update: | 2021-05-15 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-13 15:01:38 |
Package Statistics | |
---|---|
Total Downloads: | 200 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 7 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A module management in Laravel
Clara is packed as a composer package. So it can be installed quickly:
Require the composer package
composer require megaads/clara
Register the provider:
Megaads\Clara\Providers\ModuleServiceProvider
Register the facade:
Megaads\Clara\Facades\ModuleFacade
Autoloading
By default the module classes are not loaded automatically. You can autoload your modules in composer.json
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Modules\\": "app/Modules"
}
},
"extra": {
"merge-plugin": {
"include": [
"app/Modules/*/module.json"
]
}
}
}
php artisan module:make <ModuleName> ...
Folder structure
app
│
└───Modules
└───ModuleName
│
└───Config
│ app.php
│
└───Controllers
│ Controller.php
│ ...
│
└───Helpers
│ helper.php
│ ...
│
└───Middlewares
│ ExampleMiddleware.php
│ ...
│
└───Models
│ ...
│
└───Resources
│ Views
│ Assets
│ ...
│
└───Routes
│ routes.php
│ ...
│
└───Kernel.php
│
└───module.json
│
└───start.php
php artisan module:download <ZipFileURL> ...
php artisan module:enable <ModuleName> ...
php artisan module:disable <ModuleName> ...
php artisan module:remove <ModuleName> ...
php artisan module:remove-all
Using PHP
Module::action('action_name', [params]);
Using blade statement
@action('action_name', [params])
Module::onAction('action_name', function ($params) {
}, PRIORITY);
Handle a action using a controller
Module::onAction('action_name', 'Modules\Example\Controllers\HomeController@action', PRIORITY);
By default, Clara supplies actions:
Using PHP
Module::view('view_name', [params], IS_MULTI_LAYER);
Module::view('view_name', 'This is a view placeholder', IS_MULTI_LAYER);
Using blade statement
@view('view_name', [params])
Module::onView('view_name', function ($params) {
return view('module-namespace:home.index');
}, PRIORITY);
Handle a view using a controller
Module::onView('view_name', 'Modules\Example\Controllers\HomeController@index', PRIORITY);
$modules = Module::all();
$module = Module::this();
$option = Module::option('option.name');
$option = Module::option('option.name', 'option.value');
The Clara is open-sourced software licensed under the MIT license
Email: info@megaads.vn
If you find a bug, please report it here on Github