Milkncookiez
Milkncookiez

Reputation: 7407

Is there DB configuration file just for local purpose in Laravel?

In Sails, f.e., there is a local.js file which, if filled with configuration for the database, overwrites the default file in which the DB configuration is set. And this local file is ignored by GIT, by default, so that when I deploy, the username and password of my local configuration are not revealed or also I don't have to change the default configuration file all the time from local to production username and password.

So, is there something like this in Laravel 4.2, that will override the app/config/database.php file?

Upvotes: 0

Views: 128

Answers (2)

CDF
CDF

Reputation: 194

Sure you can.

First of all, Laravel has to determine the current environment using the $app->detectEnvironment(); in the /bootstrap/start.php file.

Once you get it, just create a folder with the environment name which contained files will override the production ones.

For further explaination, just have a look to these two links ( documentation and tutorial ):

http://laravel.com/docs/4.2/configuration#environment-configuration http://chrishayes.ca/blog/code/laravel-4-setting-utilizing-environments-environment-configuration

Upvotes: 1

John Corry
John Corry

Reputation: 1577

Yes.

You can create app/config/local/database.php and if your app's environment is 'local', that will override the global database config file.

Upvotes: 0

Related Questions