Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Grahame Thomson
Grahame Thomson
4,130 Points

How do I configure multiple environments in Laravel?

So I have a .env file for local development:

APP_ENV=local APP_DEBUG=false APP_KEY= **********************************

DB_HOST=127.0.0.1 DB_DATABASE=******** DB_USERNAME=************ DB_PASSWORD=************

but when I push to test or production where/how do I store details for those environments?

2 Answers

The .env file is listed in your .gitignore file and won't be uploaded. You must set them manually on the server.

Grahame Thomson
Grahame Thomson
4,130 Points

Okay. I've had more of a look and it seems that you should never commit .env to your repo. And your environment variables should be set manually on the server. Have I understood this correctly?