Bonjour,

j'ai un problème avec ma route. Lorsque je tape php artisan serve pour activer le serveur et afficher le resultat j'obtiens ceci:

"```
C:\laravel\e-comme>php artisan serve

UnexpectedValueException

Invalid route action: [HomeComponent].

at C:\laravel\e-comme\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:92
88▕ */
89▕ protected static function makeInvokable($action)
90▕ {
91▕ if (! method_exists($action, 'invoke')) {
➜ 92▕ throw new UnexpectedValueException("Invalid route action: [{$action}].");
93▕ }
94▕
95▕ return $action.'@
invoke';
96▕ }

HomeComponent was not found: Controller class HomeComponent for one of your routes was not found. Are you sure this controller exists and is imported correctly?

1 C:\laravel\e-comme\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:47
Illuminate\Routing\RouteAction::makeInvokable("HomeComponent")

2 C:\laravel\e-comme\vendor\laravel\framework\src\Illuminate\Routing\Route.php:191
Illuminate\Routing\RouteAction::parse("/", ["HomeComponent", "HomeComponent"])

C:\laravel\e-comme>



**web.php**

"```
<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () {
   // return view('welcome');
//});
Route::get('/',HomeComponent::class);
```"

**HomeComponent.php**

"```
<?php

namespace App\Http\Livewire;

use Livewire\Component;

class HomeComponent extends Component
{
    public function render()
    {
        return view('livewire.home-component')->layout('layouts.base');
    }
}
```"

2 réponses


Gusparo
Réponse acceptée

Salut, essaye de mettre un "use App\Http\Livewire\HomeComponent;" dans ton fichier web.php juste après le premier use.

MEITE
Auteur

Merci ça marche