$env = $app->detectEnvironment(array(
'local' => array('*.local'),
));
The original config files can be used in my local environment like the database.php
, cache.php
etc. But my custom config isn't getting used in my local environment.
Is there a way to add my custom config on it?
Laravel stores all the config file values into one single array. So, the "Laravel way" of overwriting the config variables after they are set is to edit the array in which they are stored: config([ // overwriting values set in config/app. php 'app.
Laravel's default .env file contains some common configuration values that may differ based on whether your application is running locally or on a production web server. These values are then retrieved from various Laravel configuration files within the config directory using Laravel's env function.
In your main Laravel folder you should have . env file which contains various settings, one row – one KEY=VALUE pair. And then, within your Laravel project code you can get those environment variables with function env('KEY').
What is the config method? The config method allows your application to get or set values in all files that are in the config directory.
If you are on Linux and Mac, you may determine your "hostname" using the "hostname" terminal command and use it in the array.
First, you need to define, what is 'local' environment
$env = $app->detectEnvironment(array(
// everything that contains 'localhost' or '127.0.0.1'
// in URL will be considered to run in local env.
'local' => array('localhost', '127.0.0.1'),
));
Then, you need to create directory named local
in app/config
. If you want to override DB settings in local env. create the file: app/config/local/database.php
and override setting in this file, for example:
'connections' => array(
'mysql' => array(
'username' => 'otherUserName',
'password' => 'otherPassword',
),
),
In this file, you do not need to specify all options, only options that are different from production/base configuration.
More info in official docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With