[英]Laravel 5: How do I change the directory of my custom config file from app/config to app/source?
I have a repository in folder app/source and a second project share the app/source with my current project. 我在文件夹app / source中有一个存储库,第二个项目与当前项目共享了app / source。 I need to move my app/config/config.php into app/source so my second project has the same data. 我需要将我的app / config / config.php移到app / source中,以便我的第二个项目具有相同的数据。 How do I configure laravel to search for my custom config in app/source/config.php instead of app/config/config.php? 如何配置laravel在app / source / config.php中而不是app / config / config.php中搜索我的自定义配置?
I've tried to update my ConfiserviceProvider class to this: 我试图将我的ConfiserviceProvider类更新为:
class ConfigServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
config([
'app/source/config.php',
]);
}
}
but this isn't working. 但这不起作用。
How do I fix this? 我该如何解决?
To include custom config file: 要包括自定义配置文件:
app('config')->set('custom', require app_path('source/config.php'));
For example if config.php file contains: 例如,如果config.php文件包含:
<?php
return [
'foo' => 'bar'
];
Access it like that: 像这样访问它:
config('config.foo'); // return 'bar'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.