Skip to content

Commit

Permalink
support for Laravel 5.5 - v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem-Schander committed Aug 31, 2017
1 parent ba7cd3b commit 0bb366c
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 397 deletions.
28 changes: 13 additions & 15 deletions README.md
Expand Up @@ -2,10 +2,8 @@
[![Laravel](https://img.shields.io/badge/laravel-5-orange.svg)](http://laravel.com)
[![Release](https://poser.pugx.org/artem-schander/l5-modular/v/stable)](https://github.com/Artem-Schander/L5Modular/releases)
[![Source](https://img.shields.io/badge/source-Artem_Schander-blue.svg)](https://github.com/Artem-Schander/L5Modular)
[![Downloads](https://img.shields.io/packagist/dt/artem-schander/l5-modular.svg)](https://packagist.org/packages/artem-schander/l5-modular)
[![License](https://poser.pugx.org/artem-schander/l5-modular/license)](https://opensource.org/licenses/MIT)
<!-- is broken -->
<!-- [![Contributor](https://img.shields.io/badge/contributor-Farhan Wazir-blue.svg)](https://github.com/farhanwazir) -->
[![Contributor](https://img.shields.io/badge/contributor-Farhan Wazir-blue.svg)](https://github.com/farhanwazir)
[![License](https://poser.pugx.org/artem-schander/l5-modular/license)](https://packagist.org/packages/artem-schander/l5-modular)

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.
Expand All @@ -25,20 +23,20 @@ Thanks to zyhn for the ["Modular Structure in Laravel 5" tutorial](http://ziyaha
The best way to install this package is through your terminal via Composer.

Run the following command from your projects root
```shell
```
composer require artem-schander/l5-modular
```
Once this operation is complete, simply add the service provider to your project's `config/app.php` and you're done.

#### Service Provider
```php
```
ArtemSchander\L5Modular\ModuleServiceProvider::class,
```

<a name="getting-started"></a>
## Getting started

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/translation if necessary.
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`.

Expand Down Expand Up @@ -67,19 +65,19 @@ laravel-project/
<a name="usage"></a>
## Usage

The generated `RESTful Resource Controller` and the corresponding `routes/web.php` make it easy to dive in. In my example you would see the output from the `Modules/FooBar/Views/index.blade.php` by opening `laravel-project:8000/foo-bar` in your browser.
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.


#### Disable modules
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:
```php
```
return [
'enable' => [
'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.
Expand All @@ -88,14 +86,14 @@ L5Modular will load all modules if there is no modules.php file in the config fo

#### Use a single `routes.php` file *(à la Laravel < v5.3)*

Since version 1.4.0 the module structure has slightly changed. Instead of using a single routes file there is a routes folder with the route `web.php` and `api.php`. No panic, the old fashioned routes file will be loaded anyways. So if you like it that way you can stick with the single routes file in the module-root folder.
Since version 1.4.0 the module structure has slightly changed. Instead of using a single routes file there is a routes folder with the route files `web.php` and `api.php`. No panic, the old fashioned routes file will be loaded anyways. So if you like it that way you can stick with the single routes file in the module-root folder.

#### Load additional classes

In some cases there is a need to load different additional classes into a module. Since Laravel loads the app using the [PSR-4](http://www.php-fig.org/psr/psr-4/) autoloading standard, you can just add folders and files almost without limitations. The only thing you should keep in mind is to name the file exactly like the class name and to add the correct namespace.
In some cases there is a need to load different additional classes into a module. Since Laravel loads the app using the PSR-4 autoloading standard, you can just add folders and files almost without limitations. The only thing you should keep in mind is to add the correct namespace.

F.a. If you want to add the `app/Modules/FooBar/Services/FancyService.php` to your module, you can absolutely do so. The file could then look like this:
```php
F.a. If you want to add the `App/Modules/FooBar/Services/FancyService.php` to your module, you can absolutely do so. The file could then look like this:
```
<?php
namespace App\Modules\FooBar\Services;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -4,7 +4,7 @@
"keywords": ["laravel", "modular", "modules", "module", "structure", "pattern", "Artem", "Schander", "l5modular", "artisan", "generator"],
"homepage": "https://github.com/Artem-Schander/L5Modular",
"license": "MIT",
"version": "1.4.0",
"version": "1.4.1",
"authors": [
{
"name": "Artem Schander",
Expand Down

0 comments on commit 0bb366c

Please sign in to comment.