I am getting the error below even though my Controller class is present in my Controllers directory;
Fatal error: Class 'App\\Http\\Controllers\\Controller' not found
Below is the content of my UserController controller (in the same directory, Controllers):
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
public function SignIn(Request $request)
{
if (Auth::attempt(['usernameEmail'=>$request['usernameEmail'],'password'=>$request['password']])) {
return redirect()->route('dashboard');
}
return redirect()->back();
}
public function getDashBoard()
{
return view('dashboard');
}
}
What am I doing wrong and how can I resolve it?
It you ran composer dump-autoload
and it didn't fixed your problem you placed your controller in wrong folder. It should be inside app\\Http\\Controllers
dir.
If it won't fix your issue, look at storage\\logs\\laravel.log
where you can find more informations about the problem, and where your problem occured. Maybe you are defining routes using wrong classname or something like that.
You get the Fatal error: Class 'App\\Http\\Controllers\\Controller' not found
error because you have no such a class in your project at the derived location.
Instead of
use App\Http\Controllers\Controller; // this is irrelevant and causing the error you get
you should have
use Illuminate\Http\Request; // this is necessary for your SingIn method
as in:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserController extends Controller
{
// your methods here
}
because one of your SignIn
method does make use of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.