在类中定义事件侦听器时,如果该类恰好位于命名空间中,我应该如何使用该Event::listen
方法定义侦听器?
namespace MyApp\Events;
class MyEventClass{
public function onUserCreated(){
Log::info('Event is fired');
}
}
Event::listen('myapp.createuser','MyApp\Events\MyEventClass@onUserCreated');
引发以下错误
Class MyApp\Events\MyEventClass does not exist