Invalid route action

What seems to be the problem:
I’ve just created a new Laravel 8 / Livewire 2.0 project. (I used Jetstream with Livewire option to create my new project). I created some new Livewire components but my routes web.php file seems to be having issues finding my Livewire components. I’m using the Livewire component as a full controller, instead of Laravel’s controller.

Here is my web.php routes file:

> <?php
> use Illuminate\Support\Facades\Route;
> 
> Route::get('/dashboard', App\Http\Livewire\LwDashboard::class)->name('dashboard.index');

My folder structure in App\Http\Livewire path is as follows:

app
  -> Http
    -> Livewire
      -> LwDashboard.php

I’ve followed the documentation from here But sadly it is not working for me.

My composer.json shows latest versions for Laravel and Livewire:

“laravel/framework”: “^8.0”,
“livewire/livewire”: “^2.0”

The error I get when loading the page is:

UnexpectedValueException
Invalid route action: [LwDarkweb].
Controller class LwDarkweb for one of your routes was not found. Are you sure this controller exists and is imported correctly?

I must have missed something super simple, what do y’all think? Let me know what other info you need, thanks :slight_smile:

Ah wait I think I may see the issue, let me try something quick.

Ok my bad, I had to use the full path of App\Http\Livewire\classname. I was trying to be too clever and added use App\Http\Livewire, and then just refer to my classname without the App\Http\Livewire path but that didn’t work. It is now routing correctly. Please ignore me, tx! :slight_smile:

1 Like