【问题标题】:Laravel Delete Event ListenerLaravel 删除事件监听器
【发布时间】:2019-01-29 08:17:03
【问题描述】:

不久前,我添加了与身份验证系统相关的所有事件和侦听器,如文档here 中所定义,并生成了所有侦听器。我现在只想使用两个监听器并清理监听器文件夹。

所以在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',
    // ],
];

然后我删除 app/Listeners 文件夹中的所有监听器。

如果我随后运行php artisan event:generate,则会收到错误消息:

ErrorException : 包括(/PATH 这里/供应商/作曲家/../../app/Listeners/LogRegisteredUser.php): 无法打开流:没有这样的文件或目录

我错过了什么?

【问题讨论】:

  • 尝试运行composer dump-autoload

标签: laravel laravel-5.7


【解决方案1】:

我遇到了同样的问题。你可以运行命令

php artisan clear-compiled

或者,

composer dump-autoload

然后运行php artisan event:generate

【讨论】:

    猜你喜欢
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多