【发布时间】:2017-09-12 09:49:02
【问题描述】:
我发现理解 Facades 有点困难。特别是如何从外观名称中找到底层类名称/位置。我已经浏览了文档,但仍然不清楚。例如,当使用Auth::login()
,我发现 Auth 门面中没有login() 方法。
class Auth extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'auth';
}
/**
* Register the typical authentication routes for an application.
*
* @return void
*/
public static function routes()
{
static::$app->make('router')->auth();
}
}
Auth门面getFacadeAccessor()方法返回一个字符串auth。但是我应该看哪个auth 类?如何解析实际类?
谢谢,
【问题讨论】:
-
这可能会有所帮助laravel.com/docs/5.5/facades#how-facades-work 如果你向下滚动一点,你会看到哪个门面对应哪个类
-
好问题。很长一段时间以来,它一直让我发疯。