Class 'app\http\controllers\..., Not Found - How to fix this Laravel error ?
LaravelSometimes while Working with Laravel applications, you can come accross any of the below error message:
Class 'App\Http\Controllers\Redirect' not found
Class 'App\Http\Controllers\Validator' not found
Class 'App\Http\Controllers\Session' not found
Class 'App\Http\Controllers\Auth' not found
Class 'App\Http\Controllers\Input' not found
Class 'App\Http\Controllers\Response' not found
Class 'App\Http\Controllers\Model' not found
Class 'App\Http\Controllers\View' not found
Class 'App\Http\Controllers\DB' not found
Here at Fixwebnode, as part of our Website Development Services, we regularly help our customers to fix related Laravel Controller issues.
The fixes mentioned here can be applied to Laravel 7,6,5, 4 version.
Table of contents [Show]
Different fixes to Class 'app\http\controllers\' Laravel issues
1. Class 'App\Http\Controllers\Redirect' not found
If you are getting error like Class 'App\Http\Controllers\Redirect' not found on controller in laravel, you can add use Redirect; at the top of YourController file along with other prefix as shown below:use Redirect;
Then, On YourController.php file, add use Redirect; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Redirect;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
2. Class 'App\Http\Controllers\Validator' not found
If you are getting error like Class 'App\Http\Controllers\Validator' not found on controller in laravel, then add use Validator; at the top of YourController file like this:use Validator;
Then, On YourController.php file, add use Validator; at the top of YourController file like the following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
3. Class 'App\Http\Controllers\Session' not found
If you are getting error like Class 'App\Http\Controllers\Session' not found on controller in laravel, the fix is to add use Session; at the top of YourController file along with other prefix:use Session;
OR
use Illuminate\Support\Facades\Session;
Then, On YourController.php file, add use Session; at the top of YourController a file like the following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Session;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
4. Class 'App\Http\Controllers\Auth' not found
If you are getting error like Class 'App\Http\Controllers\Auth' not found on controller in laravel, the fix is to add use Auth; at the top of YourController file along with other prefix just like this:use Auth;
ORIlluminate\Support\Facades\Auth;
Then, On YourController.php file, add use Auth; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
5. Class 'App\Http\Controllers\Input' not found
If you are getting error like Class 'App\Http\Controllers\Input' not found on controller in laravel, you can add use Illuminate\Support\Facades\Input; at the top of YourController file along with other prefix like this:use Illuminate\Support\Facades\Input;
Then, On YourController.php file, add use Illuminate\Support\Facades\Input; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
6. Class 'App\Http\Controllers\Response' not found
If you are getting error like Class 'App\Http\Controllers\Response' not found on controller in laravel, you can add use Response; at the top of YourController file along with other prefix just like this:use Response;
Then, On YourController.php file, add use Response; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Response;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
7. Class 'App\Http\Controllers\Model' not found
If you are getting error like Class 'App\Http\Controllers\Model' not found on controller in laravel, you should add use App\Model; at the top of YourController file along with other prefix like this:use App\ModelName;
Then, On YourController.php file, add use Illuminate\Support\Facades\Input; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\ModelName;
class YourController extends Controller
{
public function index(Request $request)
{
//your code
}
}
8. Class 'App\Http\Controllers\View' not found
If you are getting error like Class 'App\Http\Controllers\View' not found on controller in laravel, you can add use View; at the top of YourController file along with other prefix like this:
use View;
Then, On YourController.php file, add use View; at the top of YourController file like following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use View;
class YourController extends Controller
{
public function index(Request $request)
{
return \View::make('index');
}
}
9. Class 'App\Http\Controllers\DB' not found
If you are getting error like Class 'App\Http\Controllers\DB' not found on controller in laravel, you can add use DB; at the top of YourController file along with other prefix like this:
use DB;
Then, On YourController.php file, add use DB; at the top of YourController file like the following:namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
class YourController extends Controller
{
public function index(Request $request)
{
}
}
[Need help in fixing any Laravel Controller errors ? We can help you. ]
This article covers ways to fix Laravel error, Class 'App\Http\Controllers\' not found. In fact, this error happens when a "use import statements" is missing in the class of the Controller.