lundi 25 octobre 2021

Laravel Artisan event:generate command throwing a Fatal error

I'm following the official documentation for Laravel 5.7 on the events registration and generation: https://laravel.com/docs/5.7/events#generating-events-and-listeners

I have an EventServiceProvider with the following events defined:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{

    /**
     * The event handler mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\FormBeforeCreate' => [
            'App\Listeners\WebhookBeforeCreate',
        ],
        'App\Events\FormAfterCreate' => [
            'App\Listeners\NotifyAfterCreate',
            'App\Listeners\WebhookAfterCreate',
        ],
        'App\Events\FormBeforeUpdate' => [
            'App\Listeners\WebhookBeforeUpdate',
        ],
        'App\Events\FormAfterUpdate' => [
            'App\Listeners\NotifyAfterUpdate',
            'App\Listeners\WebhookAfterUpdate',
        ],
        'App\Events\FormBeforeDelete' => [
            'App\Listeners\WebhookBeforeDelete',
        ],
        'App\Events\FormAfterDelete' => [
            'App\Listeners\NotifyAfterDelete',
            'App\Listeners\WebhookAfterDelete',
        ],
        'App\Events\FormBeforeSave' => [
            'App\Listeners\WebhookBeforeSave',
        ],
        'App\Events\FormAfterSave' => [
            'App\Listeners\NotifyAfterSave',
            'App\Listeners\WebhookAfterSave',
        ],
    ];

    /**
     * The subscriber classes to register.
     *
     * @var array
     */
    protected $subscribe = [
        'App\Listeners\UserEventSubscriber',
    ];

    /**
     * Register any other events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
    }
}

The error:

When I run the command php artisan event:generate I get the following error:

PHP Fatal error:  Call to a member function listens() on null in /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/EventGenerateCommand.php on line 35

                                                           
  [Symfony\Component\Debug\Exception\FatalErrorException]  
  Call to a member function listens() on null

According to the doc, it should do this:

This command will generate any events or listeners that are listed in your EventServiceProvider. Events and listeners that already exist will be left untouched

I don't understant what I've missed since I didn't find any similar error by searching the web



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bbUyoR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire