PHPackages                             wpscholar/phpdotenv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wpscholar/phpdotenv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wpscholar/phpdotenv
===================

Loads environmental variables from a .env file.

1.0.1(6y ago)615.7k↓32.5%12GPL-2.0-or-laterPHP

Since Feb 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wpscholar/phpdotenv)[ Packagist](https://packagist.org/packages/wpscholar/phpdotenv)[ RSS](/packages/wpscholar-phpdotenv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (2)

PHP dotenv
==========

[](#php-dotenv)

A `.env` file parsing and loading library for PHP.

Automatically loads variables into a number of contexts:

- `getenv()` (default)
- `$_ENV` (default)
- `$_SERVER` (default)
- `apache_getenv` (optional)
- PHP constants (optional)
- Global variables (optional)
- A custom config array (optional)

Why?
----

[](#why)

**You should never store sensitive credentials in your code.** Storing [configuration in the environment](http://www.12factor.net/config) is one of the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is likely to change between deployment environments – such as database credentials or credentials for 3rd party services – should be extracted from the code into environment variables.

Requirements
------------

[](#requirements)

- PHP 5.4

Installation
------------

[](#installation)

Using [Composer](https://getcomposer.org/), run `composer require wpscholar/phpdotenv`.

Make sure you have a line in your code to handle autoloading:

```
