Support the ongoing development of Laravel.io →
Jobs Testing

Hello! I have a problem with Laravel 5.1.

When I try to do things like this, with facades

Event::fire(new SomeEvent());

It works great

But when I try to inject Event class in constructor like this

public function __construct(Illuminate\Events\Dispatcher $event)
{
    $this->event = $event;
    ....
}

public function handle()
{
    $this->event->fire(new SomeEvent());
    ....
}

It do not works, so I can't write a unit tests.. What I do wrong?

Thanks

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.