使用自定义包的配置文件而不在 Laravel 5 中发布。*
use config file of custom package without publishing in Laravel 5.*
我的 Laravel 自定义包有一个 config 文件。
目前我正在使用 自定义包的 config 文件,按照 docs 中所述发布它].
我只是想澄清一下,有没有一种方法可以使用自定义包的 config 文件而不在 Laravel 5 中发布它。*
您可以使用包的 ServiceProvider
的 mergeConfigFrom
方法
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/path/to/config/courier.php', 'courier'
);
}
解决了。
这是我使用的代码。
public function register()
{
if ($this->app['config']->get('custom_package') === null) {
$this->app['config']->set('custom_package', require __DIR__.'/../Config/config.php');
}
在 ServiceProvider
中 自定义包 。
我的 Laravel 自定义包有一个 config 文件。
目前我正在使用 自定义包的 config 文件,按照 docs 中所述发布它].
我只是想澄清一下,有没有一种方法可以使用自定义包的 config 文件而不在 Laravel 5 中发布它。*
您可以使用包的 ServiceProvider
的mergeConfigFrom
方法
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/path/to/config/courier.php', 'courier'
);
}
解决了。
这是我使用的代码。
public function register()
{
if ($this->app['config']->get('custom_package') === null) {
$this->app['config']->set('custom_package', require __DIR__.'/../Config/config.php');
}
在 ServiceProvider
中 自定义包 。