VanJr's avatar
Level 2

Laravel8; UI; Bootstrap; UI:Auth; Error: Target class [HomeController] does not exist

I decided to stick with Bootstrap over Tailwind.

I executed the following:

$ composer require laravel/ui
$ php artisan ui bootstrap
$ npm install && npm run dev
$ php artisan ui:auth
$ php artisan serve

And when I click on the HOME link in the WELCOME (i.e. http://127.0.0.1:8000/home), I get the following error:

Illuminate\Contracts\Container\BindingResolutionException
Target class [HomeController] does not exist.
http://127.0.0.1:8000/home

Illuminate\Container\Container::build
vendor/laravel/framework/src/Illuminate/Container/Container.php:811

Here is the new (auto generated) routes/web.php:

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

I think it may be a namespace problem but I cannot seem to see it....

0 likes
3 replies
Nakov's avatar
Nakov
Best Answer
Level 73

Have you tried to import the HomeController or try the full namespace, like this:

Route::get('/home', 'App\Http\Controllers\HomeController@index')->name('home');

As I think that Laravel in version 8 removed the default namespace from the RouteServiceProvider.

https://laravel.com/docs/8.x/routing#basic-routing

1 like

Please or to participate in this conversation.