|
1 | 1 | PHP dotenv
|
2 | 2 | ==========
|
3 | 3 |
|
4 |
| -Loads environment variables from `.env` to `getenv()`, `$_ENV` and |
5 |
| -`$_SERVER` automagically. |
| 4 | +Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically. |
6 | 5 |
|
7 |
| -This is a PHP version of the original [Ruby |
8 |
| -dotenv](https://github.com/bkeepers/dotenv). |
| 6 | + |
| 7 | + |
| 8 | +<p align="center"> |
| 9 | +<a href="https://travis-ci.org/vlucas/phpdotenv"><img src="https://img.shields.io/travis/vlucas/phpdotenv/master.svg?style=flat-square" alt="Build Status"></img></a> |
| 10 | +<a href="LICENSE"><img src="https://img.shields.io/badge/license-BSD%203--Clause-brightgreen.svg?style=flat-square" alt="Software License"></img></a> |
| 11 | +<a href="https://packagist.org/packages/vlucas/phpdotenv"><img src="https://img.shields.io/packagist/dt/vlucas/phpdotenv.svg?style=flat-square" alt="Total Downloads"></img></a> |
| 12 | +<a href="https://github.com/vlucas/phpdotenv/releases"><img src="https://img.shields.io/github/release/vlucas/phpdotenv.svg?style=flat-square" alt="Latest Version"></img></a> |
| 13 | +</p> |
9 | 14 |
|
10 |
| -[](https://travis-ci.org/vlucas/phpdotenv) |
11 | 15 |
|
12 | 16 | Why .env?
|
13 | 17 | ---------
|
| 18 | + |
14 | 19 | **You should never store sensitive credentials in your code**. Storing
|
15 | 20 | [configuration in the environment](http://www.12factor.net/config) is one of
|
16 | 21 | the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is
|
17 | 22 | likely to change between deployment environments – such as database credentials
|
18 |
| -or credentials for 3rd party services – should be extracted from the |
19 |
| -code into environment variables. |
20 |
| - |
21 |
| -Basically, a `.env` file is an easy way to load custom configuration |
22 |
| -variables that your application needs without having to modify .htaccess |
23 |
| -files or Apache/nginx virtual hosts. This means you won't have to edit |
24 |
| -any files outside the project, and all the environment variables are |
25 |
| -always set no matter how you run your project - Apache, Nginx, CLI, and |
26 |
| -even PHP 5.4's built-in webserver. It's WAY easier than all the other |
27 |
| -ways you know of to set environment variables, and you're going to love |
28 |
| -it. |
| 23 | +or credentials for 3rd party services – should be extracted from the code into |
| 24 | +environment variables. |
| 25 | + |
| 26 | +Basically, a `.env` file is an easy way to load custom configuration variables |
| 27 | +that your application needs without having to modify .htaccess files or |
| 28 | +Apache/nginx virtual hosts. This means you won't have to edit any files outside |
| 29 | +the project, and all the environment variables are always set no matter how you |
| 30 | +run your project - Apache, Nginx, CLI, and even PHP 5.4's built-in webserver. |
| 31 | +It's WAY easier than all the other ways you know of to set environment |
| 32 | +variables, and you're going to love it! |
29 | 33 |
|
30 | 34 | * NO editing virtual hosts in Apache or Nginx
|
31 | 35 | * NO adding `php_value` flags to .htaccess files
|
32 | 36 | * EASY portability and sharing of required ENV values
|
33 | 37 | * COMPATIBLE with PHP's built-in web server and CLI runner
|
34 | 38 |
|
| 39 | +PHP dotenv is a PHP version of the original [Ruby |
| 40 | +dotenv](https://github.com/bkeepers/dotenv). |
| 41 | + |
35 | 42 |
|
36 | 43 | Installation with Composer
|
37 | 44 | --------------------------
|
38 | 45 |
|
39 |
| -```shell |
40 |
| -curl -s http://getcomposer.org/installer | php |
41 |
| -php composer.phar require vlucas/phpdotenv |
| 46 | +Installation is super-easy via [Composer](https://getcomposer.org/): |
| 47 | + |
| 48 | +```bash |
| 49 | +$ composer require vlucas/phpdotenv |
42 | 50 | ```
|
43 | 51 |
|
44 |
| -Or on Existing projects |
| 52 | +or add it by hand to your `composer.json` file. |
45 | 53 |
|
46 |
| -```shell |
47 |
| -composer require vlucas/phpdotenv |
48 |
| -``` |
49 | 54 | Usage
|
50 | 55 | -----
|
| 56 | + |
51 | 57 | The `.env` file is generally kept out of version control since it can contain
|
52 | 58 | sensitive API keys and passwords. A separate `.env.example` file is created
|
53 | 59 | with all the required environment variables defined except for the sensitive
|
@@ -270,3 +276,10 @@ Contributing
|
270 | 276 | 6. Push to the branch (`git push origin my-new-feature`)
|
271 | 277 | 7. Create new Pull Request
|
272 | 278 |
|
| 279 | + |
| 280 | +For Enterprise |
| 281 | +-------------- |
| 282 | + |
| 283 | +Available as part of the Tidelift Subscription |
| 284 | + |
| 285 | +The maintainers of `vlucas/phpdotenv` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-vlucas-phpdotenv?utm_source=packagist-vlucas-phpdotenv&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) |
0 commit comments