简体   繁体   English

Laravel删除事件监听器

[英]Laravel Delete Event Listener

A while ago I added all events and listeners related to the auth system, as defined in the docs here , and generated all the listeners. 前段时间我补充说,涉及到身份验证系统中的文档中定义的所有事件和监听器在这里 ,并产生所有的听众。 I would now like to use only two listeners and clean up the Listeners folder. 我现在只想使用两个侦听器并清理Listeners文件夹。

So in EventServiceProvider I've commented out what I don't need: 因此,在EventServiceProvider我已注释掉了不需要的内容:

protected $listen = [

    Registered::class => [
        SendEmailVerificationNotification::class,
    ],

    'Illuminate\Auth\Events\Registered' => [
        'App\Listeners\LogRegisteredUser',
    ],

    // 'Illuminate\Auth\Events\Attempting' => [
    //     'App\Listeners\LogAuthenticationAttempt',
    // ],

    // 'Illuminate\Auth\Events\Authenticated' => [
    //     'App\Listeners\LogAuthenticated',
    // ],

    'Illuminate\Auth\Events\Login' => [
        'App\Listeners\LogSuccessfulLogin',
    ],

    // 'Illuminate\Auth\Events\Failed' => [
    //     'App\Listeners\LogFailedLogin',
    // ],

    // 'Illuminate\Auth\Events\Logout' => [
    //     'App\Listeners\LogSuccessfulLogout',
    // ],

    // 'Illuminate\Auth\Events\Lockout' => [
    //     'App\Listeners\LogLockout',
    // ],

    // 'Illuminate\Auth\Events\PasswordReset' => [
    //     'App\Listeners\LogPasswordReset',
    // ],

    // 'Illuminate\Auth\Events\Verified' => [
    //     'App\Listeners\LogVerifiedUser',
    // ],
];

I then delete all Listeners in the app/Listeners folder. 然后,我删除app / Listeners文件夹中的所有侦听器。

If I then run php artisan event:generate I get an error: 如果然后运行php artisan event:generate收到错误消息:

ErrorException : include(/PATH HERE/vendor/composer/../../app/Listeners/LogRegisteredUser.php): failed to open stream: No such file or directory ErrorException:include(/ PATH HERE / vendor / composer /../../ app / Listeners / LogRegisteredUser.php):无法打开流:没有这样的文件或目录

What am I missing? 我想念什么?

I had the same problem. 我有同样的问题。 you may run command 您可以运行命令

php artisan clear-compiled

or, 要么,

composer dump-autoload

and then run php artisan event:generate 然后运行php artisan event:generate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM