How to setup Local and Production environments on Laravel
One great feature of Laravel is how easy it is to setup local and dev environments.
Why would you want separate environments?
- Require separate packages for dev, and production.
- Less bloat / potential for errors on production.
- Turn off debug on production.
- Special config options for local vs production.
//First we open /bootstrap/start.php $env = $app->detectEnvironment( array( /* I use .dev for local domains via my hosts file. * PatricksPC is the name of my PC - this is * required if you want Artisan to run in local * environment automatically. * * You can get your pc name by running php artisan tinker * var_dump(gethostname()); */ 'local' => array('localhost', '*.dev', 'PatricksPC'), 'production' => array('mydomain.com') ));
Next we simply create a new folder at : App/config/local/
If you create a App.php file -this file will override the global App.php in the parent directory while working in the local environment. So you can add different providers/facades to this local version and not mess up the production version.