Lumen-framework: RouteServiceProvider is not available in lumen

Created on 2 Oct 2015  路  4Comments  路  Source: laravel/lumen-framework

I just realized that RouteServiceProvider is not available in the framework. What is the reason? Or what is the alternative to inject a new route.php file in the ServiceProvider?

Most helpful comment

You dont need to re-create RouteServiceProvider, you can define your route groups inside the bootstrap/app.php , something like this incase u don't want use default web route

$app->router->group([
    'namespace' => 'App\Http\Controllers',
    'prefix' => 'v1',
], function ($router) {
    require __DIR__.'/../routes/api-v1.php';
});

All 4 comments

The idea is you just write your own service provider. That should be pretty trivial to do. ;)

Hey @GrahamCampbell, I asked that because I am referring to the project Lumen.

Yes, Laravel seems to be pretty trivial since we have a class Illuminate\Foundation\Support\Providers\RouteServiceProvider that does all of the cache work and everything. Basically it's just a matter of extending from RouteServiceProvider and overriding the method called map.

So, since we don't have Illuminate\Foundation\Support\Providers\RouteServiceProvider into Lumen project, I am just wondering if I will need to recreate the same class in order to have the same behavior. Thanks.

I know this is closed, but it is also the top google result when I googled for this. I would like to re-ask @jairobjunior's question.

Do we need to recreate our own Illuminate\Foundation\Support\Providers\RouteServiceProvider since it is not available in lumen?

You dont need to re-create RouteServiceProvider, you can define your route groups inside the bootstrap/app.php , something like this incase u don't want use default web route

$app->router->group([
    'namespace' => 'App\Http\Controllers',
    'prefix' => 'v1',
], function ($router) {
    require __DIR__.'/../routes/api-v1.php';
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhengyuhe123 picture zhengyuhe123  路  4Comments

gfazioli picture gfazioli  路  5Comments

timrogers picture timrogers  路  3Comments

hamihaa picture hamihaa  路  3Comments

rtheunissen picture rtheunissen  路  3Comments