tback's avatar
Level 1

Possible Bug: App group prepends \App\Http\Controllers to my namespace.

$app->group(['namespace'=> '\Tback\PrometheusExporter'], function() use ($app){
    $app->get('metrics', ['as' => 'metrics', 'uses'=> 'LpeController@metrics']);
});

This route produces the following Exception:

Class App\Http\Controllers\Tback\PrometheusExporter\LpeController does not exist```
This is very odd to me. Why does Lumen prepend the namespace? It look very much like a lumen bug to me.
0 likes
4 replies
tback's avatar
Level 1

Thanks, I'll specify my route in bootstrap then.

Still doesn't make too much sense to me:

$app->group(['namespace' => 'App\Http\Controllers\Admin'], function() use ($app)
{
    // Controllers Within The "App\Http\Controllers\Admin" Namespace

    $app->group(['namespace' => 'App\Http\Controllers\Admin\User'], function() use ($app) {
        // Controllers Within The "App\Http\Controllers\Admin\User" Namespace
    });
});

from: https://lumen.laravel.com/docs/5.2/routing#route-group-namespaces

To me this seems to be a limitation that's not necessary. Users are forced to pass the whole namespace anyway.

rdelorier's avatar

Those docs are just wrong, namespaces are appended.

Please or to participate in this conversation.