Laravel 4:它支持哪些事件?

时间:2013-03-04 22:48:38

标签: laravel laravel-4

我看到this SO question关于Laravel事件,但是他们是为了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()自己解雇它们并且它有效,但显然这不是我想要的。

2 个答案:

答案 0 :(得分:6)

我在laravel wiki中找到了这个列表:http://wiki.laravel.io/Event_List_(Laravel_4)

答案 1 :(得分:3)

到目前为止,我在Laravel 4中发现了以下事件:

auth.login
auth.logout

artisan.start

illuminate.query
illuminate.log

eloquent.updating
eloquent.updated
eloquent.creating
eloquent.created

locale.changed

composing: {viewName}

我会在找到更多

时更新此列表