Php Laravel 4具有困难的时间跟踪定位方法
我正在使用PHPStorm,如果它有帮助的方法,我也在MacOSX系统上 我们的代码中有以下行:Php Laravel 4具有困难的时间跟踪定位方法,php,laravel-4,Php,Laravel 4,我正在使用PHPStorm,如果它有帮助的方法,我也在MacOSX系统上 我们的代码中有以下行: $config = Config::get('regions'); 首先,我想找到class Config的位置。嗯,这行不通 print_r(get_class(Config)); 所以我这样做: $test = new Config; //works print_r(get_class(Config)); 这给了我: \Illuminate\Support\Facades\Config
$config = Config::get('regions');
首先,我想找到class Config
的位置。嗯,这行不通
print_r(get_class(Config));
所以我这样做:
$test = new Config; //works
print_r(get_class(Config));
这给了我:
\Illuminate\Support\Facades\Config
这反过来又非常简短:
<?php namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Config\Repository
*/
class Config extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'config'; }
}
Laravel使用立面提供静态界面。基本上,它们是服务容器中对象和变量的快捷方式 退房 Laravel允许您使用静态调用:
Config::get('x');
它从Facade类提供的密钥下的服务容器解析它。对于配置,这是'Config'
在Laravel 5.4中,其注册于以下容器中:
src/illumb/Foundation/start.php
/*
|--------------------------------------------------------------------------
| Register The Configuration Repository
|--------------------------------------------------------------------------
|
| The configuration repository is used to lazily load in the options for
| this application from the configuration files. The files are easily
| separated by their concerns so they do not become really crowded.
|
*/
$app->instance('config', $config = new Config(
$app->getConfigLoader(), $env
));
您会在同一个文件中注意到:
use Illuminate\Config\Repository as Config;
因此,您要查找的类是illumb\Config\Repository
,它具有get()
方法
这也是门面本身所暗示的;)
一些外观是在框架内处理的,其他外观是由应用程序本身中的服务提供商提供的,您可以从中找到它们绑定到容器的类。以及为什么需要它?这个方法只是从app/config文件夹返回regions.php文件中的内容。虽然我很感激这个贡献,但这不是我要问的问题。在将来的某些情况下,一些开发人员(比如我)可能想知道如何定位特定的方法,或者其他特定的方法。谢谢。我确实看到了@see提示,但出于某种原因(可能是用户错误:),我没有找到
get()
方法,我肯定可能是找错了地方。
/**
* @see \Illuminate\Config\Repository
*/