jminayat / modules-laravel
modular laravel applications
Installs: 187
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 1
Type:project
Requires
- php: ^7.0
- chumper/zipper: 1.0.x
Requires (Dev)
- orchestra/testbench: ^3.5
- phpunit/phpunit: ^6
README
jminayat/modules-laravel
is a package for the administration of your laravel application in modules. compatible with Laravel version 5.5 .
Installation
Install the package through the composer.
composer require jminayat/modules-laravel
You need to load the module folder since it does not load automatically. You can autoload your modules using psr-4
.
Edit main composer file, and add:
{ "autoload": { "psr-4": { "App\\": "app/", "Modules\\": "modules/" } } }
Do not forget to execute composer dump-autoload
.
You can publish the Migrations.
php artisan vendor:publish --provider="JMinayaT\Modules\ModulesServiceProvider" --tag="migrations"
After the migration has been published, you can create the table of modules by executing the migrations:
php artisan migrate
You can publish the Config file (it's optional).
php artisan vendor:publish --provider="JMinayaT\Modules\ModulesServiceProvider" --tag="config"
When published, the config/modules.php
Config file contains:
<?php return [ /* * Name of the table to use * default value but you may easily change it to any table you like. */ 'table_name' => 'modules', ];
Usage
Creating A Module
To create a new module, simply run the following command:
php artisan module:create <module-name>
<module-name>
- Replace with the name of the desired module.module description
- Write the description of the module created.
To automatically add controller, model and migration when creating a new module use: -c -d -m
php artisan module:create <module-name> -c -d -m
-c
or--controller
- Create controller.-d
or--model
- Create model.-m
or--migration
- Create migration.
Folder Structure
modules/
├── Blog/
├── Controllers/
├── Database/
├── migrations/
├── Models/
├── Resources/
├── Assets/
├── lang/
├── views/
├── Route/
├── web.php
├── api.php
├── module.json
Artisan Commands
Note that the command names use "test" as the name of the example module
module:active
activate | disable module, use true or false.
php artisan module:active test true
module:create
create a new module.
php artisan module:create test
options
-c
or--controller
- Create controller.-d
or--model
- Create model.-m
or--migration
- Create migration.
module:delete
delete module.
php artisan module:delete test
module:install
Install module from zip file.
php artisan module:install var/this-path/test.zip
module:list
show list of all modules.
php artisan module:list
module:make-controller
Create a new module controller.
php artisan module:make-controller test TestController
module:make-middleware
Create a new module middleware class.
php artisan module:make-middleware test TestMiddleware
module:make-request
Create a new module request class.
php artisan module:make-request test TestRequest
module:make-model
Create a new module model.
php artisan module:make-model test TestModel
options
-m
or--migration
- Create migration.
module:make-migration
Create a new module migration.
php artisan module:make-migration test create_tests_table
module:make-seeder
Create a new module seeder class.
php artisan module:make-seeder test testSeeder
module:make-factory
Create a new module factory class.
php artisan module:make-factory test testFactory
module:make-test
Create a new module test class.
php artisan module:make-test test userTest
module:make-policy
Create a new module policy class.
php artisan module:make-policy test testPolicy
module:publish
Publish module zip file.
php artisan module:publish test
module:up
Up config file module json.
php artisan module:up test
module:migrate
Migrate database for all modules.
php artisan module:migrate
For migrate a specific module to use:
php artisan module:migrate test
module:rollback
Rollback the last module database migration.
php artisan module:rollback
For rollback a specific module to use:
php artisan module:rollback test
module:seed
Module Seed the database with records.
php artisan module:sedd
For seed a specific module to use:
php artisan module:seed test
Facade Methods
Get all modules.
Module::all();
Get a specific module.
Module::get('test');
Get all active modules.
Module::getEnabled();
Get all disabled modules.
Module::getDisabled();
Check the specified module. If it exists, will return true, otherwise false.
Module::has('test');
Count all modules.
Module::count();
Install a module using the zip file.
Module::install('path/file.zip');
Migrate database the specified module.
Module::moduleMigrate('test');
Rollback database the specified module.
Module::moduleRollback('test');
Migrate the database to all modules
Module::moduleMigrateAll();
Rollback database to all modules.
Module::moduleRollbackAll();
Module Methods
get entity from a specific module.
$module = Module::get('test');
Get module name in studlycase.
$module->studlyName();
Get the status of the module if it is active or disabled.
$module->status();
Enable the specified module.
$module->active();
Enable the specified module.
$module->disable();
Delete the specified module.
$module->delete();
Get module Path.
$module->getPath();
Get module Json file.
$module->getModuleJson();
License
The MIT License (MIT). Please see License File for more information.