我看到了这个关于 Laravel 事件的 SO question,但它们适用于 Laravel 3。我已经尝试了所有这些,但它们都不起作用。这是我的代码global.php
:
$event_names = array("laravel.done", "laravel.log", "laravel.query", "laravel.resolving", "laravel.composing", "laravel.started", "laravel.controller.factory", "laravel.config.loader", "laravel.language.loader", "laravel.view.loader", "laravel.view.engine", "view.filter", "eloquent.saving", "eloquent.updated", "eloquent.created", "eloquent.saved", "eloquent.deleting", "eloquent.deleted");
foreach ($event_names as $event_name) {
echo "Listening to {$event_name}<br/>";
Event::listen($event_name, function($event) {
var_dump($event);
exit;
});
}
它只是开始监听,但没有触发任何事件。我尝试过自己使用它们来触发它们Event::fire()
并且它有效,但显然这不是我想要的。