Setup multiple environment for laravel 5
This article will explain you, how to setup Multiple Environment for Laravel 5
When you install laravel 5 one .env file will be created during installation.
In this article I will setup two environment, local & production, check the below steps
1. Create two Environment files name as local & production.
- Create a file with the name of .local.env
- Create a file with the name of .production.env
2. Copy the .env file content and paste in .local.env and use APP_ENV=local because this file will be used for local Environment, which will look like
3. Copy the .env file content and paste in .production.env and use APP_ENV=production because this file will be used for production Environment, which will loook like
4. Remove all content from .env file. Use local for local Environment and production for production Environment
.env file for local Environment look like
.env file for production Environment look like
5. Create new php file and named it, environment.php, save it into this folder: app/bootstrap/environment.php and then paste the below code in this file.
6. Include your environment.php file in bootstrap file. Paste it inside your bootstrap/app.php file.
7. After that you can check your environment using your terminal
Change local as production and then use the below command from your terminal
- // Write production in .env file and then check the environment using below artisan command
- php artisan env
- Current application environment: production
Nguồn: http://phpcodehub.co.in
Comments
Post a Comment