clarence / lumen-default-routes
Default routes for laravel
Installs: 35
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/clarence/lumen-default-routes
Requires
- php: >=5.5
- laravel/lumen-framework: 5.2.*
Requires (Dev)
- mockery/mockery: ^0.9.4
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2025-10-23 05:58:16 UTC
README
With this library, you can easily add "module/controller/action" style routes for Lumen.
Install
Suggest install it via composer:
composer require clarence/lumen-default-routes
Then, register the DefaultRouteProvider. For lumen, please register \Clarence\LumenDefaultRoutes\DefaultRouteProvider::class in bootstrap/app.php.
// bootstrap/app.php $app = new Laravel\Lumen\Application( realpath(__DIR__.'/../') ); //... $app->group(['namespace' => 'App\Http\Controllers'], function ($app) { require __DIR__.'/../app/Http/routes/main_routes.php'; }); $app->register(Clarence\LumenDefaultRoutes\DefaultRouteProvider::class); // add: register default routes below registered all your own routes
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 asdefault-routes.controller-prefix.- In
FooController,Controlleris the class name suffix. It can be configurated asdefault-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.