-
Notifications
You must be signed in to change notification settings - Fork 12
Development Environments and Configuration in Laravel
Chirag Gude edited this page Mar 6, 2015
·
3 revisions
-
All configurations and settings in
/app/config/
will be used by your Laravel app in Production -
To check your current environment run:
php artisan env
You should get a response similar to:Current application environment: production
-
To create separate configurations for Local Development and Production, copy database.php, mail.php and app.php from
/app/config/
to/app/config/local/
-
Run the following command in Terminal or Command Prompt to know your hostname:
hostname
-
Next, make the required changes in /bootstrap/start.php. In my case, my development machine's hostname is
CPG-PC
, so I would replacelocal-machine-hostname
toCPG-PC
$env = $app->detectEnvironment(array(
'local' => array('local-machine-hostname'),
'staging' => array('staging-server-hostname'),
'production' => array('production-server-hostname'),
));
- Now if you run:
php artisan env
You should get get a response similar to:Current application environment: local
. This means that all settings in/app/config/local/
will take precedence over settings in/app/config/
Environment & Configurations for Production
Extra Tips
- You can get rid of all configurations in the
/app/config/local/
that are repeated in/app/config/
. Just keep the unique configurations. - Enable debug mode by going to /app/config/local/app.php and set
'debug' = true,
- Service providers for development only tools like
Generators
andDebugbar
should go in /app/config/local/app.php
'providers' => append_config(array(
'Way\Generators\GeneratorsServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
)),
Command Line Tips
- Run the
hostname
command in CMD and then change /bootstrap/start.php - Shorten command line path in Windows by running the following ommand:
prompt $g
- For a better developer workflow in Windows, use PowerShell instead of Command Prompt
- In Windows Explorer, just go to the Address Bar at the top and type
powershell
and press Enter. A Powershell command window opens with the current directory. - In Windows, create an alias for Laravel:
Set-Alias art "php artisan"
- In Linux, create an alias for Laravel:
alias art='php artisan'