Laravel 5 - 获取包配置
Laravel 5 - Get Package Config
通常我们可以通过这样的方式获取配置:
$value = Config::get('app.timezone');
如果想获取包中的配置,我们可以这样做:
$value = Config::get('package::configfile')
如何 link 我的包中的配置文件,以便我可以那样使用它?
请务必阅读文档中的 Package Development 章节。
在 Laravel 5 中不再有配置 "namespaces"。您只需在服务提供商中像这样加载您的配置:
$this->publishes([
__DIR__.'/path/to/config/file.php' => config_path('package/file.php'),
]);
并像这样访问它:
Config::get('package.file');
或:
config('package.file');
通常我们可以通过这样的方式获取配置:
$value = Config::get('app.timezone');
如果想获取包中的配置,我们可以这样做:
$value = Config::get('package::configfile')
如何 link 我的包中的配置文件,以便我可以那样使用它?
请务必阅读文档中的 Package Development 章节。
在 Laravel 5 中不再有配置 "namespaces"。您只需在服务提供商中像这样加载您的配置:
$this->publishes([
__DIR__.'/path/to/config/file.php' => config_path('package/file.php'),
]);
并像这样访问它:
Config::get('package.file');
或:
config('package.file');