<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
// Registered::class => [ SendEmailVerificationNotification::class, ],
//一定要在app前加上''单引号,不然容易在provider下生成文件如:app\provider\app\events\usersignupevent。这里面的中括号[ ]“千万不要记,否则事件不会响应
'App\Events\UserSignUpEvent'=>[ 'App\Listeners\SendEmailForNewUserListen',],
];

本文深入探讨了Laravel框架中事件监听的配置方法,详细解释了如何在EventServiceProvider类中注册事件及其监听器,包括如何正确使用监听映射数组以确保事件能够被正确触发。

1006

被折叠的 条评论
为什么被折叠?



