Package Data | |
---|---|
Maintainer Username: | ahmadhossiny |
Maintainer Contact: | info@rayantools.com (Rayan Tools) |
Package Create Date: | 2017-01-30 |
Package Last Update: | 2017-01-31 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-19 03:18:14 |
Package Statistics | |
---|---|
Total Downloads: | 15 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 3 |
Total Forks: | 2 |
Total Open Issues: | 0 |
![Contributor](https://img.shields.io/badge/contributor-Farhan Wazir-blue.svg)
This package gives you the ability to use Laravel 5 with module system.
You can simply drop or generate modules with their own controllers, models, views, translations and a routes file into the app/Modules
folder and go on working with them.
Thanks to zyhn for the "Modular Structure in Laravel 5" tutorial. Well explained and helped a lot.
The best way to install this package is through your terminal via Composer.
Add the following line to the composer.json
file and fire composer update
"RayanTools/l5-modular": "dev-master"
Once this operation is complete, simply add the service provider to your project's config/app.php
RayanTools\L5Modular\ModuleServiceProvider::class,
The built in Artisan command php artisan make:module name [--no-migration] [--no-translation]
generates a ready to use module in the app/Modules
folder and a migration if necessary.
Since version 1.3.0 you can generate modules named with more than one word, like foo-bar
.
This is how the generated module would look like:
laravel-project/
app/
|-- Modules/
|-- FooBar/
|-- Controllers/
|-- FooBarController.php
|-- Models/
|-- FooBar.php
|-- Views/
|-- index.blade.php
|-- Translations/
|-- en/
|-- example.php
|-- routes.php
|-- helper.php
The generated RESTful Resource Controller
and the corresponding routes.php
make it easy to dive in. In my example you would see the output from the Modules/FooBar/Views/index.blade.php
when you open laravel-project:8000/foo-bar
in your browser.
In case you want to disable one ore more modules, you can add a modules.php
into your projects app/config
folder. This file should return an array with the module names that should be loaded.
F.a:
return [
'enable' => array(
"customer",
"contract",
"reporting",
),
];
In this case L5Modular would only load this three modules customer
contract
reporting
. Every other module in the app/Modules
folder would not be loaded.
L5Modular will load all modules if there is no modules.php file in the config folder.
In case you want to change template, you can edit a view.php
into your projects app/config
folder and add key template
with value template name.
return [
'template' => 'default'
];
default template generated would look like:
laravel-project/
resources/
themes/
|-- default/
|-- Module1/
|-- index.blade.php
|-- Module2/
|-- index.blade.php
|-- Module3/
|-- index.blade.php
Since version 1.3.0 you have to follow the upper camel case
name convention for the module folder. If you had a Modules/foo
folder you have to rename it to Modules/Foo
.
Also there are changes in the app/config/modules.php
file. Now you have to return an array with the key enable
instead of list
.
L5Modular is licensed under the terms of the MIT License (See LICENSE file for details).