Class App\Http\Controllers\AuthController does not exist Laravel 5.2
Asked Answered
R

7

10

My whole application, made in Laravel 5.2, is working perfectly fine but when i tried to get list of routes through following command:

php artisan route:list

It shows me following error:

[ReflectionException] Class App\Http\Controllers\AuthController does not exist

i tried to add namespace aswell:

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

then it shows me following error:

[ReflectionException]
Class App\Http\Controllers\Auth\Auth\AuthController does not exist

My routes file is:

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

Update: content of Router.php

public function auth()
{
    // Authentication Routes...
    $this->get('login', 'Auth\AuthController@showLoginForm');
    $this->post('login', 'Auth\AuthController@login');
    $this->get('logout', 'Auth\AuthController@logout');

    // Registration Routes...
    $this->get('register', 'Auth\AuthController@showRegistrationForm');
    $this->post('register', 'Auth\AuthController@register');

    // Password Reset Routes...
    $this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
    $this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
    $this->post('password/reset', 'Auth\PasswordController@reset');
}

Please help! Thanks

Reduce answered 22/3, 2016 at 8:28 Comment(3)
remove 'namespace'=>'Auth', working ?Liba
did you run the composer dump-autoload command?Mauretta
The dump-autoload command updates information autoloader. This command is useful when you add new classes and do not want to run the install or update commandAlrzc
F
2

I cannot comment so I'm going to ask have you run php artisan make:auth and with laravel 5.2 you dont need your routes in your Routes.php. All you have to have in your href="{{ url('/login') }}"

Frederic answered 6/4, 2016 at 14:24 Comment(0)
T
2

in my case just remove:

     'namespace' => 'App\Http\Controllers',

namespace => App\Http\Controllers

Tenebrous answered 14/10, 2019 at 13:59 Comment(0)
J
0

I got the same issue and I found out what was the issue. My code was look like this:

namespace App\Http\Controllers\Auth;
namespace App\Repositories;

And I changed to this:

namespace App\Repositories;
namespace App\Http\Controllers\Auth;

Issue solved for me.

Jorgenson answered 26/7, 2016 at 8:59 Comment(1)
You only want one namespace declaration. This looks like the second declaration was overriding the first, until you switched them around. You only need one.Forerunner
M
0

I got the same problem. Just use

Route::get('/login',[
    'uses' => 'Auth\AuthController@login',
    'as'   => 'login'
]);
Mutable answered 7/9, 2016 at 8:58 Comment(0)
L
0

In laravel 5.2 you can use php artisan make:auth , this creates a line

Route::auth() in your routes.php file. And creates all the necessary

routes.

Also your namespacing solution would probably work if you remove the Auth part from

'Auth\AuthController@showRegistrationForm'

and leave it like

'AuthController@showRegistrationForm'.

Lach answered 7/9, 2016 at 9:19 Comment(0)
W
0

I had this issue while trying to implement multi-auth with two registration forms in Laravel 8.69. My controller AuthController existed. While extending class controller my code read class RegisterController extends Controller instead of class AuthController extends Controller

Wiburg answered 24/11, 2021 at 16:8 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Handlebar
G
-1

I had this issue while trying to implement multi-auth with two registration forms in Laravel 8.69. My controller AuthController existed. While extending class controller my code read class RegisterController extends Controller instead of class AuthController extends Controller

Glosseme answered 26/8 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.