Route::auth() and namespacing

- 1 answer

Ad

I have used make:auth to create the login scaffold which works nicely in the base app. However I am creating a package so I have moved the files to their respective places in my package.

I have namespaced the route created by the make:auth app to

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'Package\Namespace\[email protected]');
});

When I comment out Route::auth(); everything seems to work fine. When I keep Route::auth I get an error

Class Auth\AuthController does not exist

I cannot understand what the issue is. I don't know much about the auth() helper function.

Ad

Answer

Ad

Obvious error...

Within Router.php the auth() function namespaces are in relation to the default Controllers namespace.

Removing the auth() function and adding all the namespaced routes into the routes file of course did the trick

// Authentication Routes...
Route::get('login', 'App\Http\Controllers\Auth\[email protected]');
Route::post('login', 'App\Http\Controllers\Auth\[email protected]');
Route::get('logout', 'App\Http\Controllers\Auth\[email protected]');

// Registration Routes...
Route::get('register', 'App\Http\Controllers\Auth\[email protected]');
Route::post('register', 'App\Http\Controllers\Auth\[email protected]');

// Password Reset Routes...
Route::get('password/reset/{token?}', 'App\Http\Controllers\Auth\[email protected]');
Route::post('password/email', 'App\Http\Controllers\Auth\[email protected]');
Route::post('password/reset', 'App\Http\Controllers\Auth\[email protected]');
Ad
source: stackoverflow.com
Ad