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

Ashraam's avatar
Level 41

Listening events from package in Livewire

Hey,

So i've made a package and I wanted to implement events.

In the laravel app that use the package, I've set a listener on the Livewire component:

#[On('cart.updated')]
public function update(string $id)
{
    dd($id);
}

But it does nothing, so I've tried to debug.

In the AppServiceProvider I've added this code:

Event::listen('*', function ($event, array $data) {
    if ($event === 'cart.updated') {
        logger($event, $data);
    }
});

I can see the event in the log, yet it is not captured by the Livewire component.

Here is how I dispatch the event in the package:

$this->events->dispatch('cart.updated', [
    'id' => $itemId,
]);

Does anyone has an idea to make this work ?

Thanks

0 likes
1 reply

Please or to participate in this conversation.