Clarence-pan / lumen-default-routes by Clarence-pan

Default routes for laravel
35
2
2
Package Data
Maintainer Username: Clarence-pan
Maintainer Contact: clarence-pan@foxmail.com (Clarence)
Package Create Date: 2016-04-22
Package Last Update: 2016-04-22
Language: PHP
License: MIT
Last Refreshed: 2024-05-01 15:04:27
Package Statistics
Total Downloads: 35
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 1
Total Open Issues: 1

Default Routes For Lumen

build status

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:

  1. \App\Http\Controllers\ is the namespace prefix of the controller. It can be configurated as default-routes.controller-prefix.
  2. In FooController, Controller is the class name suffix. It can be configurated as default-routes.controller-suffix.
  3. doGetBar is the actual method to be executed. It is do + <HTTP_METHOD> + <action>. And it should be a public method. Otherwise a 404 or 405 HTTP error will be thrown.
  4. If \App\Http\Controllers\FooController@doGetBar cannot be found, \App\Http\Controllers\Foo\BarController@doGetIndex will be tried.