使用自定义包的配置文件而不在Laravel 5中发布*

bes*_*ant 1 publish config package laravel laravel-5

我的Laravel自定义软件包有一个配置文件。

目前,我正在按照docs中所述通过发布自定义包的配置文件来使用它。

我只想澄清一下,有没有一种方法可以使用自定义包的配置文件而不在Laravel 5中发布它?*

huu*_*uuk 5

您可以使用mergeConfigFrom包的 ServiceProvider 的方法

/**
 * Register bindings in the container.
 *
 * @return void
 */
public function register()
{
    $this->mergeConfigFrom(
        __DIR__.'/path/to/config/courier.php', 'courier'
    );
}
Run Code Online (Sandbox Code Playgroud)


bes*_*ant 5

解决了。

这是我使用的代码。

public function register()
    {

        if ($this->app['config']->get('custom_package') === null) {
            $this->app['config']->set('custom_package', require __DIR__.'/../Config/config.php');
        }
Run Code Online (Sandbox Code Playgroud)

ServiceProvider定制包