[Solved] Target class [App/Http/Controllers/Auth/LoginController] does not exist

I want to use Facebook Api.
my web.php file:

?php

use IlluminateSupportFacadesAuth;
use IlluminateSupportFacadesRoute;
use AppHttpControllersMembersController;
use LaravelSocialiteFacadesSocialite;
use AppHttpControllersAuthLoginController; 

Route::get('login/facebook', 'App/Http/Controllers/Auth/[email protected]');
Route::get('login/facebook/callback', 
'App/Http/Controllers/Auth/[email protected]leProviderCallBack');

my LoginController which is in in AppHttpControllersAuth

namespace AppHttpControllersAuth;

use AppHttpControllersController;
use AppProvidersRouteServiceProvider;
use IlluminateFoundationAuthAuthenticatesUsers;
use LaravelSocialiteFacadesSocialite;
use IlluminateSupportFacadesRoute;

class LoginController extends Controller
{
use AuthenticatesUsers;


protected $redirectTo = RouteServiceProvider::HOME;

public function __construct()
{
    $this->middleware('guest')->except('logout');
}

public function redirectToProvider() 
{
    return  Socialite::driver('facebook')->redirect();
}

public function handleProviderCallBack()
{
    $user = Socialite::driver('facebook')->user();
}

}

in browser i got error Target class [App/Http/Controllers/Auth/LoginController] does not exist.

can anyone help me?
Thanks!

Enquirer: Leo

||

Solution #1:

You use a forward / instead of a backslash in your route controller namespace:

Route::get('login/facebook/callback', 
'[email protected]');

change the slashes for both routes and clear the cache using php artisan route:cache

If you are using Laravel 8 Tim’s comment is the right syntax:

use AppHttpControllersAuthLoginController;  
Route::get('login/facebook', [LoginController::class,'redirectToProvider']);
Respondent: Gert B.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

New ride at Perth's Adventure World a ‘swing on steroids’ - Australasian Leisure Management npp pharma the truth about anabolic steroid drugs and professional sports