Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 How to switch from Production mode

When I run $ php artisan env I get;

Current application environment: production

How can I change this to development or something similar? So I can see errors.. I have read a lot of the documentation but it is not at all easy for a newbie to understand. I don't have server config experience, really.

I'm sure there is "smart" way to do this, but all I am interested in, for now, is manually changing the environment. How do I do this?

like image 927
mikelovelyuk Avatar asked Feb 25 '15 13:02

mikelovelyuk


People also ask

How do I change to production mode in Laravel?

env file is to allow you to have different settings depending on which machine you are running your application. So on your production server, the . env file settings would be different from your local development enviroment. So each server/environment has it's own .

How do I change environment in Laravel?

env file, where you store all your environment configuration. To define your environment, you should put APP_ENV=local to this file. If you use service like Laravel Forge, it provides you nice simple way of storing your environment data.

Can I use php artisan serve for production?

In production you should be using a fully featured web server such as nginx, Apache, lighttpd, etc. Laravel + Vue. js app cannot run without php artisan serve .


3 Answers

Laravel 5 gets its enviroment related variables from the .env file located in the root of your project. You just need to set APP_ENV to whatever you want, for example:

APP_ENV=development

This is used to identify the current enviroment. If you want to display errors, you'll need to enable debug mode in the same file:

APP_DEBUG=true

The role of the .env file is to allow you to have different settings depending on which machine you are running your application. So on your production server, the .env file settings would be different from your local development enviroment.

like image 89
Bogdan Avatar answered Oct 12 '22 09:10

Bogdan


Laravel 5 uses .env file to configure your app. .env should not be committed on your repository, like github or bitbucket. On your local environment your .env will look like the following:

# .env
APP_ENV=local

For your production server, you might have the following config:

# .env
APP_ENV=production
like image 53
Nino Paolo Avatar answered Oct 12 '22 09:10

Nino Paolo


Do not forget to run the command php artisan config:clear after you have made the changes to the .env file. Done this again php artisan env, which will return the correct version.

like image 40
Sergio Paiva Avatar answered Oct 12 '22 10:10

Sergio Paiva