Support the ongoing development of Laravel.io →
posted 9 years ago
Architecture
Last updated 2 years ago.
0

Easiest thing to do is read the official documentation- it's based on a community plugin called DotEnv:

https://github.com/vlucas/phpdotenv

The basics are to just create file called .env in the root of your project, and set any variables you need.

You can then reference them using the function dotenv('variable_name') and you're good to go.

The only key thing is that the .env file is environment specific and should not be checked-in as part of your code repository.

0

jayhealey said:

Easiest thing to do is read the official documentation- it's based on a community plugin called DotEnv:

https://github.com/vlucas/phpdotenv

The basics are to just create file called .env in the root of your project, and set any variables you need.

You can then reference them using the function dotenv('variable_name') and you're good to go.

The only key thing is that the .env file is environment specific and should not be checked-in as part of your code repository.

But how to use two different env's and select them? For example one for production and other for local development?

0

But how to use two different env's and select them? For example one for production and other for local development?

http://laravel.com/docs/5.0/configuration

0

Note: Instead of 'dotenv()', use Laravel's helper 'env()'.

On my local setup I have a .env with local settings and on my production server I have the same .env file with production credentials/values.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

nonamez nonamez Joined 5 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.