Skip to content
Advertisement

Defining custom namespaces on routes in laravel 5.6

So Consider the following:

Route::middleware('web')
    ->namespace('AppModulesConfigControllers')
    ->group(function () {
        Route::get('config', ['as' => 'config.index',  'uses' => 'Config@index']);
        Route::put('config', ['as' => 'config.update', 'uses' => 'Config@update']);
        Route::patch('config', 'Config@update');
    });

This explodes when I hit any of these routes because:

Class AppHttpControllersAppModulesConfigControllersConfig does not exist

Is there not a way in laravel 5.6 to say: No I don’t want to use AppHttpControllers I want to use the namespace I specified?

Advertisement

Answer

Try with a slash

->namespace('AppModulesConfigControllers')

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement