Here is the answer:
You need to add an import in your web.php file:
use App\Http\Controllers\HomeController;
or take a look into the other answer above :)
Hi, i just installed laravel 8, so I tryed to use Laravel/ui with vue but the home controller is giving me this error:
Illuminate\Contracts\Container\BindingResolutionException
Target class [HomeController] does not exist.
http://127.0.0.1:8000/home
I uset used this commands to install Laravel ui
$ composer require laravel ui
$ php artisan ui vue --auth
$ npm install
$ npm run dev
After that use the migration but it didn't worked. Any help is apreciated.
To App/Providers/RouteServiceProvider.php add $namespace
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
}
Docs: https://laravel.com/docs/8.x/releases (look for Routing Namespace Updates)
Edited: Also don't forget to add namespace in the boot method of RouteServiceProvider
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->namespace($this->namespace) // this line
->group(base_path('routes/web.php'));
Route::prefix('api')
->middleware('api')
->namespace($this->namespace) // this line
->group(base_path('routes/api.php'));
});
}
Please or to participate in this conversation.