clarence/laravel-default-routes
Default routes for laravel
14
10
| Install | |
|---|---|
composer require clarence/laravel-default-routes |
|
| Latest Version: | v1.0.6 |
| PHP: | >=5.5 |
| License: | MIT |
| Last Updated: | Apr 22, 2016 |
| Links: | GitHub · Packagist |
Maintainer: Clarence-pan
Default Routes For Laravel
With this library, you can easily add "module/controller/action" style routes for Laravel.
Install
Suggest install it via composer:
composer require clarence/laravel-default-routes
Then, register the DefaultRouteProvider. For example, add \Clarence\LaravelDefaultRoutes\DefaultRouteProvider::class to the providers section in config/app.php.
// config/app.php
return [
//...
'providers' => [
//...
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Clarence\LaravelDefaultRoutes\DefaultRouteProvider::class, // add DefaultRouteProvider below the RouteServiceProvider
//...
],
//...
];
Routes Maps
foo/bar will be mapped to \App\Http\Controllers\FooController@doGetBar by default.
Note:
\App\Http\Controllers\is the namespace prefix of the controller. It can be configurated aslaravel-default-routes.controller-prefix.- In
FooController,Controlleris the class name suffix. It can be configurated aslaravel-default-routes.controller-suffix. doGetBaris the actual method to be executed. It isdo+<HTTP_METHOD>+<action>. And it should be apublicmethod. Otherwise a404or405HTTP error will be thrown.- If
\App\Http\Controllers\FooController@doGetBarcannot be found,\App\Http\Controllers\Foo\BarController@doGetIndexwill be tried.