2017 © Pedro Peláez
 

library laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

image

thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  • Wednesday, February 14, 2018
  • by thejawker
  • Repository
  • 1 Watchers
  • 1 Stars
  • 167 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

Latest Version on Packagist Build Status Quality Score Total Downloads, (*1)

This package works with Laravel 5.5. It is very much inspired by the great Freek van der Herten with their Blender Package, where he has a Macro for a module. This really resonates with the CRUD/Restful approach on routing., (*2)

Installation

Require the package from Composer:, (*3)

``` bash composer require thejawker/laravel-route-module-macro, (*4)


As of Laravel 5.5 it will magically register the package. ## Usage You can add `Route::module('name', ['only'](optional), ['options](optional))` in any of your routes files. The second parameter will allow you to `only` use specific actions, and the third being general options. Refer to the [Laravel docs](https://laravel.com/docs/5.4/controllers#resource-controllers) for those. ### Examples: #### Full Resource routes/api.php ```php Route::module('posts');
$ php artisan route:list
+-----------+-----------------------------------------+---------------+---------------------------------------------------------------------------+
| Method    | URI                                     | Name          | Action                                                                    |
+-----------+-----------------------------------------+---------------+---------------------------------------------------------------------------+
| POST      | api/posts                               | posts.store   | App\Http\Controllers\PostsController@store                                |
| GET|HEAD  | api/posts                               | posts.index   | App\Http\Controllers\PostsController@index                                |
| GET|HEAD  | api/posts/create                        | posts.create  | App\Http\Controllers\PostsController@create                               |
| DELETE    | api/posts/{post}                        | posts.destroy | App\Http\Controllers\PostsController@destroy                              |
| PUT|PATCH | api/posts/{post}                        | posts.update  | App\Http\Controllers\PostsController@update                               |
| GET|HEAD  | api/posts/{post}                        | posts.show    | App\Http\Controllers\PostsController@show                                 |
| GET|HEAD  | api/posts/{post}/edit                   | posts.edit    | App\Http\Controllers\PostsController@edit                                 |
+-----------+-----------------------------------------+---------------+---------------------------------------------------------------------------+

Only Resource

routes/api.php, (*5)

Route::module('posts', ['store']);
$ php artisan route:list
+-----------+-----------------------------------------+---------------+----------------------------------------------------------------------------+
| Method    | URI                                     | Name          | Action                                                                     |
+-----------+-----------------------------------------+---------------+----------------------------------------------------------------------------+
| POST      | api/posts                               | posts.store   | App\Http\Controllers\PostsController@store                                 |
+-----------+-----------------------------------------+---------------+----------------------------------------------------------------------------+

Nested Resources

This will enforce you to write Controllers that make sense. A nested users.posts will require you to create a UserPostsController with the required actions. routes/api.php, (*6)

Route::module('users.posts');
$ php artisan route:list
+-----------+-----------------------------------------+---------------------+----------------------------------------------------------------------------+
| Method    | URI                                     | Name                | Action                                                                     |
+-----------+-----------------------------------------+---------------------+----------------------------------------------------------------------------+
| POST      | api/users/{user}/posts                  | users.posts.store   | App\Http\Controllers\UserPostsController@store                             |
| GET|HEAD  | api/users/{user}/posts                  | users.posts.index   | App\Http\Controllers\UserPostsController@index                             |
| GET|HEAD  | api/users/{user}/posts/create           | users.posts.create  | App\Http\Controllers\UserPostsController@create                            |
| DELETE    | api/users/{user}/posts/{post}           | users.posts.destroy | App\Http\Controllers\UserPostsController@destroy                           |
| PUT|PATCH | api/users/{user}/posts/{post}           | users.posts.update  | App\Http\Controllers\UserPostsController@update                            |
| GET|HEAD  | api/users/{user}/posts/{post}           | users.posts.show    | App\Http\Controllers\UserPostsController@show                              |
| GET|HEAD  | api/users/{user}/posts/{post}/edit      | users.posts.edit    | App\Http\Controllers\UserPostsController@edit                              |
+-----------+-----------------------------------------+---------------------+----------------------------------------------------------------------------+

Test

This package definitely needs some extensive testing., (*7)

bash composer test, (*8)

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

14/02 2018

dev-master

9999999-dev https://github.com/thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  Sources   Download

MIT

The Requires

 

The Development Requires

thejawker route-module laravel-route-module-macro

14/02 2018
12/09 2017

0.0.4

0.0.4.0 https://github.com/thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  Sources   Download

MIT

The Requires

 

The Development Requires

thejawker route-module laravel-route-module-macro

12/09 2017

0.0.3

0.0.3.0 https://github.com/thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  Sources   Download

MIT

The Requires

 

The Development Requires

thejawker route-module laravel-route-module-macro

12/09 2017

0.0.2

0.0.2.0 https://github.com/thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  Sources   Download

MIT

The Requires

 

The Development Requires

thejawker route-module laravel-route-module-macro

12/09 2017

0.0.1

0.0.1.0 https://github.com/thejawker/laravel-route-module-macro

Exposes a module concept to enforce a CRUD and Restful way of routing and naming convention.

  Sources   Download

MIT

The Requires

 

The Development Requires

thejawker route-module laravel-route-module-macro