Extra Config Settings for Lumen

Extra Config Settings for Lumen

In Lumen there's no config directory. This is to keep the framework as light as possible.

However there are times when you need to add a few settings of your own. Actually this is really quick and easy.

In your .env file put the new setting that you need

			
				

APP_NEW_CONFIG=setting_value

Make a new directory under the app directory and call it "config". Inside make a new file and call it what you like, eg: extra_config.php

In that file put an array like this with your own config names. Note: You can put a default value to be used if the .env file setting is not set.

			
				

<?php

return [

    'custom_setting' => env('APP_NEW_CONFIG', 'default'),

];

Finally tell Lumen what you have done!

Open the bootstrap/app.php and put

			
				

$app->configure('extra_config');

--------------------------------------------------------

Put it after this

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

But before this

return $app;

--------------------------------------------------------


Then you just use it the same way you do in Laravel

			
				

config('extra_config.custom_setting')