Livewire

Dependency Injection in Livewire v4

February 01, 2026 1 min read 12 views

Livewire v4 supports dependency injection.

In mount()

public function mount(UserService $users): void
{
    $this->users = $users->all();
}

In Actions

public function save(PostRepository $repo): void
{
    $repo->create($this->form);
}

Type-Hinted Properties

public function boot(Logger $logger): void
{
    $logger->info('Component booted');
}
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!