我在哪里可以获得Laravel事件的完整列表(由核心库触发)?

2022-08-30 16:55:12

我想知道Laravel核心库触发了哪些事件。我想获取完整的列表,例如 和 .laravel.querylaravel.done

官方文档列出了四个事件,但我认为Laravel的活动比这四个事件更多!


答案 1

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

和 都是与错误相关的事件。这些在文件中设置,以便您可以看到默认侦听器是什么。500404routes.php

我想指出的是,有另一个变体,其中包含正在更新的类名。eloquent.{event}

eloquent.{event}: {classname}

我不会说这绝对是一切,但至少应该是99%。


答案 2

除了Jason Lewis的回答,我还有一些要补充的。我只是搜索了功能,并提出了Laravel 5的以下列表,fire()

$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));

推荐