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

时间:2017-05-19 06:19:50

标签: laravel laravel-5 package config publish

我的Laravel Custom软件包有一个 config 文件。

目前我正在使用自定义程序包的配置文件,方法是按照 docs 中的说明发布它。

我只想澄清一下,有没有办法使用自定义程序包的 config 文件而不在 Laravel 5中发布。*

2 个答案:

答案 0 :(得分:4)

解决了它。

这是我使用过的代码。

public function register()
    {

        if ($this->app['config']->get('custom_package') === null) {
            $this->app['config']->set('custom_package', require __DIR__.'/../Config/config.php');
        }
自定义程序包ServiceProvider中的

答案 1 :(得分:3)

您可以使用程序包的ServiceProvider

中的mergeConfigFrom方法
/**
 * Register bindings in the container.
 *
 * @return void
 */
public function register()
{
    $this->mergeConfigFrom(
        __DIR__.'/path/to/config/courier.php', 'courier'
    );
}
相关问题