我在哪里可以获得 Laravel 事件的完整列表(由核心库触发)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13059744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can I get a complete list of Laravel events (fired by the core libraries)?
提问by Omid Kamangar
I want to know what events are fired by Laravel core libraries. I want to get the complete list, such as laravel.query
and laravel.done
.
我想知道 Laravel 核心库触发了哪些事件。我想获取完整列表,例如laravel.query
和laravel.done
。
There are four events listed at the official docs, but I think Laravel has more events than these four!
回答by Jason Lewis
Laravel doesn't actually fire as many events as you'd think. While it does make use of the Event system it's there for developers to use within there applications. Anyway, here's a list I compiled.
Laravel 实际上并没有像你想象的那样触发那么多事件。虽然它确实利用了事件系统,但它可供开发人员在那里的应用程序中使用。无论如何,这是我编制的清单。
laravel.done
laravel.log
laravel.query
laravel.resolving
laravel.composing: {viewname}
laravel.started: {bundlename}
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
eloquent.booted: {$model}
eloquent.booting: {$model}
500
404
The 500
and 404
are both error related events. These are set in the routes.php
file so you can see what the default listener is.
的500
和404
都是错误相关的事件。这些设置在routes.php
文件中,因此您可以查看默认侦听器是什么。
I'd like to point out that the eloquent.{event}
have another variation containing the class name that is being updated.
我想指出的是,eloquent.{event}
还有另一个包含正在更新的类名的变体。
eloquent.{event}: {classname}
I'm not going to say this is absolutely everything but it should be at least 99% of it.
我不会说这绝对是一切,但至少应该是其中的 99%。
回答by pinkal vansia
In addition to Jason Lewis answer, I have few more to add. I simply searched for fire()
function and came up with following list for Laravel 5,
除了 Jason Lewis 的回答之外,我还有一些要补充的。我只是简单地搜索了fire()
函数并为 Laravel 5 提供了以下列表,
$this->events->fire('auth.attempt', $payload);
$this->events->fire('auth.login', [$user, $remember]);
$this->events->fire('auth.logout', [$user]);
$this->events->fire('cache.'.$event, $payload);
$this->laravel['events']->fire('cache:clearing', [$storeName]);
$this->laravel['events']->fire('cache:cleared', [$storeName]);
$events->fire('artisan.start', [$this]);
$this->events->fire('illuminate.query', array($query, $bindings, $time, $this->getName()));
$this->events->fire('connection.'.$this->getName().'.'.$event, $this);
$this['events']->fire('bootstrapping: '.$bootstrapper, [$this]);
$this['events']->fire('bootstrapped: '.$bootstrapper, [$this]);
$this['events']->fire('locale.changed', array($locale));
$this['events']->fire($class = get_class($provider), array($provider)); //after provider registered.
$this->app['events']->fire('kernel.handled', [$request, $response]);
$this->dispatcher->fire('illuminate.log', compact('level', 'message', 'context'));
$this->events->fire('mailer.sending', array($message));
$this->events->fire('illuminate.queue.failed', array($connection, $job, $data));
$this->events->fire('illuminate.queue.stopping');
$this->events->fire('router.matched', [$route, $request]);
$this->events->fire('composing: '.$view->getName(), array($view));
$this->events->fire('creating: '.$view->getName(), array($view));
回答by Akash
Here are a few of them more, got them while dumping static::$events
这里还有一些,在倾倒时得到的 static::$events
laravel.config.loader
laravel.view.loader
laravel.language.loader
laravel.view.engine
404
Not really sure if overriding these would work, as they are internally called
不确定覆盖这些是否有效,因为它们在内部被称为
回答by ralphowino
For those looking for the list of Laravel 4 events, you can check jasonlewis list at http://jasonlewis.me/article/laravel-events
对于那些寻找 Laravel 4 事件列表的人,您可以在http://jasonlewis.me/article/laravel-events查看 jasonlewis 列表