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

DaW-S's avatar
Level 1

How to Trigger Livewire Component Method from an Artisan Command

Hello all, I'm trying to trigger a Livewire component method from an event that is fired in an Artisan command. However, I can't figure out how to make this work in Livewire.

What I'm Trying to Do:

I have a scheduled command defined in console.php, which updates data in the database. After this update, I need to notify a Livewire component and trigger one of its methods to update the UI dynamically.

Current Setup:

In console.php: I have an Artisan command that looks like this:

Artisan::command('app:update', function () {
    // Perform some updates here...

    // Fire an event
    event('command-updated');
});

In Livewire Component: I’m trying to listen for the event using the #[On] attribute:

use Livewire\Attributes\On;

#[On('command-updated')]
$this->someFunction();

public function someFunction()
{
// code
}

Environment:

Laravel: 11.x Livewire: 3.x PHP: 8.2

I'll be really glad if someone know how to do it correct. Thank you.

0 likes
3 replies
tykus's avatar

You would need to use Laravel Echo to broadcast from the application to the Livewire component.

1 like
Snapey's avatar

You could poll in Livewire view and then in the render method, check if the database has been updated since it last checked.

Alternatively your command could change the state of cache which is detected by the Livewire component.

Otherwise, reverb broadcast to the client which then refreshes the component.

1 like
DaW-S's avatar
Level 1

I think changing cache will be the perfect solution for my project. Thank your guys!

Please or to participate in this conversation.