[英]Laravel: Permanently override config of dependencies from a Laravel Package before publishing them
I am developing a Laravel Package which installs a list of dependencies.我正在开发一个安装依赖项列表的 Laravel Package。 The dependencies have their own configuration files to be published after installation.
依赖项有自己的配置文件,安装后要发布。
What we need is to auto (to avoid doing it manually) modify the config files of these dependencies by our package before/after publishing them and placing them in app/config .我们需要的是在发布它们之前/之后通过我们的 package 自动(避免手动)修改这些依赖项的配置文件并将它们放在app/config中。
I found some solutions like using mergeConfigFrom()
in register method of Package's service provider.我找到了一些解决方案,例如在 Package 的服务提供者的注册方法中使用
mergeConfigFrom()
。 But it doesn't modify file content itself, just loads the merged config.但它不会修改文件内容本身,只是加载合并的配置。 We need to modify config file's content by the package that we developing so that we don't need to change config file manually after package installation.
我们需要通过我们开发的 package 修改配置文件的内容,这样我们就不需要在安装 package 后手动更改配置文件。
For example, we install Laravel Horizon as a dependency the our package.例如,我们安装Laravel Horizon作为 package 的依赖项。 Horizon publishes a config file called
horizon.php
in app/config . Horizon 在app/config中发布了一个名为
horizon.php
的配置文件。 We need to auto modify some values for app/config/horizon.php before or after publishing that config file.我们需要在发布该配置文件之前或之后自动修改app/config/horizon.php的一些值。
Any help will be much appreciated.任何帮助都感激不尽。 Thanks:)
谢谢:)
This is currently not possible.目前这是不可能的。 Look at
Illuminate\Foundation\Console\VendorPublishCommand
in the laravel framework source code.查看 laravel 框架源代码中的
Illuminate\Foundation\Console\VendorPublishCommand
。
horizon.php
config in your package by publishing it on the same file. horizon.php
配置来完全替换它。horizon.php
horizon.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.