在多租户环境中
您可以将这些设置合并到中间件内的公共配置中,或者在您知道自己在哪个站点时:
config('common');
config('brg.settings'); // inside each have the same keys
config('ssc.settings'); // inside each have the same keys
所以说你想要
common.settings
哪里
settings
来自任何一个
brg.settings
或
scc.settings
您可以尝试如下操作:
config([
'common' => array_merge(
config('brg'),
config('common')
)
]);
如果你想修改它
轴承设置
成为常用密钥,请尝试以下操作:
config([
'common' => array_merge(
config('brg.settings'),
config('common')
)
]);
更新-用于共享(复制)文件夹方法
假设您的配置文件夹具有:
config/common.php
config/brg/settings.php
然后您可以尝试从创建符号链接
config/brg/settings.php
到
config/settings.php
$ cd config
$ ln -s brg/settings.php settings.php
你甚至可能想移动
brg/settings.php
从config文件夹中
sites/brg/settings/php
为了避免Laravel构建所有站点配置的组合,只需使用config中的symlink即可。
或者
作为部署的一部分,您可以创建一个Artisan命令来创建您需要的物理配置文件,比如,
config/site/settings.php
考虑到.env中的站点。
我认为将特定于站点的配置移出config文件夹仍然很好,以避免laravel需要解析不需要的文件。