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

JulienFantino's avatar

livewire/update not found

Hello I installed laravel 11 , breeze, livewire 3.0 and powergrid 5. I have got an error in my form when i'm trying to use it for update(click button). In console i'got this error : javascript?v=1712920837:1253 POST https: //MYDNS/livewire/update 404 (Not Found)

This is my code in ressource\views\components\layouts\app.blade.php

    <title>{{ $title ?? 'Page Title' }}</title>
</head>
<body>
    {{ $slot }}
    @livewireScriptConfig
</body>

This is what i'got in my app.js: import './bootstrap'; import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm'; import Clipboard from '@ryangjchandler/alpine-clipboard' Alpine.plugin(Clipboard) Livewire.start()

In my blade i have this code: TEST {{ $count }}

               <button wire:click="increment">+</button>
               <button wire:click="decrement">-</button>

    </div>
</div>

and in my livewire Counter.php

namespace App\Livewire; use Livewire\Component;

class Counter extends Component { public $count = 1;

public function increment()
{
    $this->count++;
}

public function decrement()
{
    $this->count--;
}

public function render()
{
    return view('livewire.counter');
}

} in my web.php: Route::get('/counter', Counter::class)->name('counter');

I type this commands : php artisan optimize:clear and npm run build

Could you help me please ? I have no idear anymore. Thanks :)

0 likes
3 replies
JulienFantino's avatar
JulienFantino
OP
Best Answer
Level 1

Hello , I solved my livewire error I copy past vendor/livewire/livewire/dist repository to public/livewire.

I added in my web.php Livewire::setScriptRoute(function ($handle) { return Route::get('TEST/public/livewire/livewire.js', $handle); }); Livewire::setUpdateRoute(function ($handle) { return Route::post('TEST/public/livewire/update', $handle); });

I added @livewireStyles in the @livewireScriptConfig in in ressources\views\layouyts\app.blade.php:

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

    <!-- Scripts -->
    @vite(['resources/css/app.css', 'resources/js/app.js'])

    @livewireStyles

</head>
<body class="font-sans antialiased">


<div class="min-h-screen bg-gray-100 dark:bg-gray-900">
        @include('layouts.navigation')

        <!-- Page Heading -->
        @isset($header)
            <header class="bg-white dark:bg-gray-800 shadow">
                <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                    {{ $header }}
                </div>
            </header>
        @endisset

        <!-- Page Content -->
        <main>
            {{ $slot }}
        </main>
    </div>
@livewireScriptConfig
</body>

in my components\layouts\app.blade.php

<x - app - layout>( I add spaces carreful) {{ $slot }} </ x - app - layout >( I add spaces carreful)

This is my counter.blade.php

<div>
       <h1>{{ $count }}</h1>

    <button wire:key="increment" wire:click="increment">+</button>

    <button  wire:key="decrement" wire:click="decrement">-</button>

    <br>  <br>
        <form wire:submit="save">
    <label>
        <input type="checkbox"  wire:key="checkBox1" wire:model.live="checkBox1" required> Option 1 (Obligatoire)
    </label>
    <br>
    @if (!$checkBox3 AND !$checkBox4)
        <label>
            <input wire:key="checkBox2" wire:model.live="checkBox2"   type="checkbox"  value="checked" > Option 2
        </label><br>
        check BOX 2: {{var_export($checkBox2)}} <br><br>

    @endif

    @if (!$checkBox2)
        <div>
            <label>
                <input wire:key="checkBox3" type="checkbox" wire:model.live="checkBox3"  > Checkbox 3
            </label>
        </div>
        <br>
        check BOX 3: {{var_export($checkBox3)}} <br><br>

        <div>
            <label>
                <input wire:key="checkBox4" type="checkbox" wire:model.live="checkBox4" > Checkbox 4
            </label>
        </div>
        <br>
        check BOX 4: {{var_export($checkBox4)}} <br><br>
    @endif <br>
    <button wire:key="save" type="submit">Save</button>

    @if($checkBox2)
        <br> coucou
    @endif
    </form>
</div>

This is my counter.php

class Counter extends Component { #[Validate('nullable')] public $count = 1;

public function increment() :void
{
    $this->count++;
}

public function decrement() :void
{
    $this->count--;
}

public $checkBox1 = false;

public $checkBox2 = false;

public $checkBox3 = false;

public $checkBox4 = false;
public function updatedCheckBox2()
{
    if ($this->checkBox2) {
        $this->checkBox3 = false;
        $this->checkBox4 = false;
    }
}

public function updatedCheckBox3()
{
    if ($this->checkBox3 || $this->checkBox4) {
        $this->checkBox2 = false;
    }
}

public function updatedCheckBox4()
{
    if ($this->checkBox3 || $this->checkBox4) {
        $this->checkBox2 = false;
    }
}
public function rules()
{
    return [
        'checkBox1' => 'nullable',
        'checkBox2' => 'nullable',
        'checkBox3' => 'nullable',
        'checkBox4' => 'nullable',
    ];
}

public function save()
{       $this->validate();
    return redirect('powergrid');    
}
public function render()
{
    return view('livewire.counter');
}

}

1 like

Please or to participate in this conversation.