I created an event and listener in Laravel, but the listener doesn't fire. It does actually fire on my colleague's machine. That makes me think that the actual code works and that the configuration is in order.
Listener:
<?php
namespace App\Listeners\Consensus;
use App\Events\Consensus\ManualGroupChannelNotificationEvent;
use Illuminate\Support\Facades\Log;
/**
* Class ManualGroupChannelNotificationListener
* @package App\Listeners\Consensus
*/
class ManualGroupChannelNotificationListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param ManualGroupChannelNotificationEvent $event
* @return void
*/
public function handle(ManualGroupChannelNotificationEvent $event)
{
Log::debug('Listener');
}
}
Event:
<?php
namespace App\Events\Consensus;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Support\Facades\Log;
/**
* Class ManualGroupChannelNotificationEvent
* @package App\Events\Consensus
*/
class ManualGroupChannelNotificationEvent
{
use Dispatchable;
/*
* ExternalComment constructor.
*
* @param Comment $comment
* @param User $currentUser
*/
public function __construct()
{
Log::debug('Event');
}
}
EventServiceProvider:
protected $listen = [
'App\Events\Consensus\ManualGroupChannelNotificationEvent' => [
'App\Listeners\Consensus\ManualGroupChannelNotificationListener',
],
];
Firing the event:
event(new ManualGroupChannelNotificationEvent());
I ran all commands to clear cache etc., but still it doesn't work.
php artisan clear-compiled
php artisan config:clear
php artisan cache:clear
composer dump-autoload
php artisan queue:restart
If this code works on another machine, what else can I do to make it work on mine?
Other info:
- My logging does work; the Event-message is logged.
- Other, similar events do work.
from Laravel EventListener doesn't fire
No comments:
Post a Comment