Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Swaz's avatar
Level 20

How is the Laravel 12 starter kit doing this?

I was playing around the new Laravel 12 starter kits and found this Logout livewire action.

I tried to do this in my existing livewire 3 project and the route doesn't even get registered. So clicking submit gives you 404.

How does this work in the starter kit?

// routes/auth.php
Route::post('logout', App\Livewire\Actions\Logout::class)
    ->name('logout');
// app/Livewire/Actions/Logout.php
namespace App\Livewire\Actions;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;

class Logout
{
    public function __invoke()
    {
        Auth::guard('web')->logout();

        Session::invalidate();
        Session::regenerateToken();

        return redirect('/');
    }
}
<form method="POST" action="{{ route('logout') }}" class="w-full">
    @csrf
    <flux:menu.item as="button" type="submit">
        Logout
    </flux:menu.item>
</form>
0 likes
5 replies
jlrdw's avatar

Is is calling an action in the vendor folder?

Swaz's avatar
Level 20

@jlrdw Nope, this code is taken directly from the new Livewire starter kit.

Snapey's avatar

do you have flux installed on your application?

Without flux, those <flux tags will be ignored by blade and by your browser.

Laravel 12 includes a cutdown flux library.

Swap the button for whatever html/css you have in your project for a sumbmit button.

Swaz's avatar
Level 20

@Snapey I don't have flux installed, but my code is just using a regular button.

<form method="POST" action="{{ route('logout') }}">
    @csrf
    <button type="submit" icon="right-from-bracket">
        Logout
    </button>
</form>

The issue is with the route not being registered. I'm not sure why this works in the Livewire preset but not in my project.

Route::post('logout', App\Livewire\Actions\Logout::class)
Swaz's avatar
Swaz
OP
Best Answer
Level 20

Never mind, I just had to run route:clear. All good now.

Please or to participate in this conversation.