Search code examples
laravellaravel-5packageconfigpublish

use config file of custom package without publishing in Laravel 5.*


I have a config file for my Laravel Custom package.

Currently I am using custom package's config file by publishing it as mentioned in the docs.

I just want to clarify that, Is there a way to use custom package's config file without publishing it in Laravel 5.*


Solution

  • Solved it.

    Here's the code that I used.

    public function register()
        {
    
            if ($this->app['config']->get('custom_package') === null) {
                $this->app['config']->set('custom_package', require __DIR__.'/../Config/config.php');
            }
    

    in the ServiceProvider for the custom package.