I went to take Laravel 8 for a spin today, but it seems the Route facade cannot find controllers anymore.
The route /home
gives me this error:
Target class [HomeController] does not exist.
I get a similar error when I run: php artisan route:list
Illuminate\Contracts\Container\BindingResolutionException
Target class [Auth\LoginController] does not exist.
at C:\...\vendor\laravel\framework\src\Illuminate\Container\Container.php:811
811 throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
Thanks to lagbox, I ended up adding namespace('App\Http\Controllers')
to the web route in RouteServiceProvider boot method:
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->namespace('App\Http\Controllers')
->group(base_path('routes/web.php'));
That did the trick for me. Any better solutions would be most welcome.
If this is a fresh install of Laravel 8, there is no namepsace defined in the RouteServiceProvider
to be applied to the your routes. You can try to wrap the Auth::routes()
call in a route group that declares the namespace App\Http\Controllers
, or go about this in a different way. (assuming you have installed laravel/ui
)
Route::namespace('App\Http\Controllers')->group(function () {
Auth::routes();
});
If you want to know how to deal with the lack of namespace being defined for your routes:
https://stackoverflow.com/a/63808132/2109233
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With