Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php Laravel ~ Attribute [controller] does not exist

I am trying to set up an Route Controller in my Laravel project and I have set up the controller and also the route.

However, when I load the route in the web.php then it produces an error when I try to navigate to that page in the browser of Attribute [controller] does not exist

Here is the code..

<?php
   namespace CMS\Http\Controllers\Auth;

   use CMS\Http\Controllers\Controller;
   use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{

use AuthenticatesUsers {
    logout as performLogout;
}

/**
 * Where to redirect users after login.
 *
 */
protected $redirectTo;

/**
 * Create a new controller instance.
 *
 */

public function __construct()
{
    $this->redirectTo = route('backend.dashboard');
    $this->middleware('guest')->except('logout');
}

public function logout(Request $request)
{
    $this->performLogout($request);
    return redirect()->route('auth.login');
}
}

And then in the web.php I have this...

Route::controller('auth', 'Auth\LoginController', [
    'getLogin' => 'auth.login'
]);
like image 321
cmiotk Avatar asked Apr 23 '17 14:04

cmiotk


People also ask

Does not exist controller laravel?

“Target class Controller does not exist” issue comes in Laravel 8. One simple trick can solve this issue. This error comes in Laravel new version because there is no namespace prefix being applied to your route groups that your routes are loaded into.

How do I fix target class controller does not exist?

To Solve Target class controller does not exist in Laravel 8 Error In Laravel 8 You have to use Route as given Below: Route::get('/register', 'App\Http\Controllers\UserController@register'); OR use App\Http\Controllers\UserController; Route::get('/register', [UserController::class, 'register']); Now, your error must be ...


1 Answers

The controller method is deprecated since Laravel 5.3. But now, you can use the resource method, which is meant for the same purpose as the controller method.

Like This:

Route::resource('auth', 'LoginController');

or

Route::get('/auth','LoginController');

Route::post('/auth','LoginController');
like image 133
RïshïKêsh Kümar Avatar answered Oct 10 '22 22:10

RïshïKêsh Kümar