15
votes

when i run below command in my terminal it shows below code instead of routes

php artisan route:list



 <html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="1;url=http://localhost/login" />

        <title>Redirecting to http://localhost/login</title>
    </head>
    <body>
        Redirecting to <a href="http://localhost/login">http://localhost/login</a>.
    </body>
</html>

[Symfony\Component\Debug\Exception\FatalThrowableError] Fatal error: Class 'App\Http\Controllers\Redirect' not found

5

5 Answers

23
votes

The only thing that you have to do is to add:

use Redirect;

in your controller just after namespace line or put \ before you call Redirect:: i.e.:

return \Redirect::back();
16
votes

You have to import the class. This is the one you need:

use Illuminate\Support\Facades\Redirect;
3
votes

You can't run php artisan route:list if any of the routes and their related controllers have errors.

In this case, it looks like you have a controller that has an error which is that you're using the Redirect facade without importing it first, so it's looking for the Redirect class in the same namespace as the controller, i.e. App\Http\Controllers\Redirect.

Locate the class that is using the Redirect facade and add Use Redirect to the top of the file and that should sort it hopefully!

2
votes

Add \ before Redirect the function

return \Redirect::back();

It works fine for me in laravel 5.3

1
votes

I use in Laravel 8 this:

return redirect()->back();