|
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 |
| 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> |
| 14 | + |
| 15 | + |
| 16 | +Why .env? |
| 17 | +--------- |
| 18 | + |
| 19 | +**You should never store sensitive credentials in your code**. Storing |
| 20 | +[configuration in the environment](http://www.12factor.net/config) is one of |
| 21 | +the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is |
| 22 | +likely to change between deployment environments – such as database credentials |
| 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! |
| 33 | + |
| 34 | +* NO editing virtual hosts in Apache or Nginx |
| 35 | +* NO adding `php_value` flags to .htaccess files |
| 36 | +* EASY portability and sharing of required ENV values |
| 37 | +* COMPATIBLE with PHP's built-in web server and CLI runner |
| 38 | + |
| 39 | +PHP dotenv is a PHP version of the original [Ruby |
8 | 40 | dotenv](https://github.com/bkeepers/dotenv).
|
9 | 41 |
|
10 |
| -[](https://travis-ci.org/vlucas/phpdotenv) |
| 42 | + |
| 43 | +Installation with Composer |
| 44 | +-------------------------- |
| 45 | + |
| 46 | +Installation is super-easy via [Composer](https://getcomposer.org/): |
| 47 | + |
| 48 | +```bash |
| 49 | +$ composer require vlucas/phpdotenv |
| 50 | +``` |
| 51 | + |
| 52 | +or add it by hand to your `composer.json` file. |
11 | 53 |
|
12 | 54 |
|
13 | 55 | UPGRADING FROM V3
|
@@ -46,37 +88,6 @@ For more details, please see the
|
46 | 88 | the [upgrading guide](UPGRADING.md).
|
47 | 89 |
|
48 | 90 |
|
49 |
| -Why .env? |
50 |
| ---------- |
51 |
| - |
52 |
| -**You should never store sensitive credentials in your code**. Storing |
53 |
| -[configuration in the environment](http://www.12factor.net/config) is one of |
54 |
| -the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is |
55 |
| -likely to change between deployment environments – such as database credentials |
56 |
| -or credentials for 3rd party services – should be extracted from the code into |
57 |
| -environment variables. |
58 |
| - |
59 |
| -Basically, a `.env` file is an easy way to load custom configuration variables |
60 |
| -that your application needs without having to modify .htaccess files or |
61 |
| -Apache/nginx virtual hosts. This means you won't have to edit any files outside |
62 |
| -the project, and all the environment variables are always set no matter how you |
63 |
| -run your project - Apache, Nginx, CLI, and even PHP 5.4's built-in webserver. |
64 |
| -It's WAY easier than all the other ways you know of to set environment |
65 |
| -variables, and you're going to love it! |
66 |
| - |
67 |
| -* NO editing virtual hosts in Apache or Nginx |
68 |
| -* NO adding `php_value` flags to .htaccess files |
69 |
| -* EASY portability and sharing of required ENV values |
70 |
| -* COMPATIBLE with PHP's built-in web server and CLI runner |
71 |
| - |
72 |
| - |
73 |
| -Installation with Composer |
74 |
| --------------------------- |
75 |
| - |
76 |
| -```shell |
77 |
| -composer require vlucas/phpdotenv |
78 |
| -``` |
79 |
| - |
80 | 91 | Usage
|
81 | 92 | -----
|
82 | 93 | The `.env` file is generally kept out of version control since it can contain
|
|
0 commit comments