L
L
Living4tomorrow2019-11-19 23:28:28
Laravel
Living4tomorrow, 2019-11-19 23:28:28

Laravel doesn't register the lisener for the event, what's the problem?

I am going through a laracast course, I repeated everything as in the video, the event starts, but the lisener does not. Here is the code:
Event

<?php

namespace App\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ProjectCreated
{
    use Dispatchable, SerializesModels;

    public $project;

    public function __construct($project)
    {
        $this->project = $project;
    }
}

Lisener
<?php

namespace App\Listeners;

use App\Events\ProjectCreated;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class SendProjectCreatedNotification
{
    public function handle(ProjectCreated $event)
    {
        die('Listener');
    }
}

EventServiceProvider
<?php

namespace App\Providers;

use App\Events\ProjectCreated;
use App\Listeners\SendProjectCreatedNotification;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        'App\Events\ProjectCreated' => [
            'App\Listeners\SendProjectCreatedNotification',
        ],
    ];
}

The event starts, the leesener does not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gian_tiaga, 2019-11-20
@gian_tiaga

Where is the start of the event itself?

E
Eugene, 2019-11-21
@Eujene

What do the logs say? Logger did?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question