PHPackages                             phoole/env - 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. [Framework](/categories/framework)
4. /
5. phoole/env

ActiveLibrary[Framework](/categories/framework)

phoole/env
==========

Simple environment variables loader library for PHP

1.1.0(6y ago)319Apache-2.0PHPPHP &gt;=7.2.0

Since Sep 30Pushed 6y ago2 watchersCompare

[ Source](https://github.com/phoole/env)[ Packagist](https://packagist.org/packages/phoole/env)[ RSS](/packages/phoole-env/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

env
===

[](#env)

[![Build Status](https://camo.githubusercontent.com/d28bf05bbfa894932bfaeddfb41e6dc45b40fd508b05c9054d710dbe2b27c923/68747470733a2f2f7472617669732d63692e636f6d2f70686f6f6c652f656e762e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/phoole/env)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6fe922751bd87d062ae86d4e0dc730b1af3da99a99cda7a95d04111a0a24ef0c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70686f6f6c652f656e762f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phoole/env/?branch=master)[![Code Climate](https://camo.githubusercontent.com/625fe4501c849f2c6b950cb0935da1531f10a82f9385a6dddbe5b6cf4980cbff/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f70686f6f6c652f656e762f6261646765732f6770612e737667)](https://codeclimate.com/github/phoole/env)[![PHP 7](https://camo.githubusercontent.com/7e3be07b01fa3cbbe0e708cea548554efdca6e66d56fe2fa57e17ea05ee04923/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70686f6f6c652f656e76)](https://packagist.org/packages/phoole/env)[![Latest Stable Version](https://camo.githubusercontent.com/122601851fdf57642b6719c933414ecb0a9e900460db83b42d1c5bc2e9e05762/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f70686f6f6c652f656e76)](https://packagist.org/packages/phoole/env)![License](https://camo.githubusercontent.com/01fb3370e846019a4d1eb5e74f38604bec77144718d3f6c5b8565014401f7270/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686f6f6c652f656e76)

Simple environment variables loader library for PHP. It loads environment variables from a .env file. It requires PHP 7.2+ and is compliant with [PSR-1](http://www.php-fig.org/psr/psr-1/ "PSR-1: Basic Coding Standard"), [PSR-4](http://www.php-fig.org/psr/psr-4/ "PSR-4: Autoloader"), [PSR-12](http://www.php-fig.org/psr/psr-2/ "PSR-12: Extended Coding Style Guide").

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

[](#installation)

Install via the `composer` utility.

```
composer require "phoole/env"

```

or add the following lines to your `composer.json`

```
{
    "require": {
       "phoole/env": "1.*"
    }
}
```

Usage
-----

[](#usage)

- Put your environments in file `.env`. By default, existing environment variables are **not overwritten**.

    ```
    # this is comment line
    BASE_DIR = /usr/local  # spaces allowed

    # use reference here
    APP_DIR = ${BASE_DIR}/app   # /usr/local/app

    # use bash style :- or :=
    TMP_DIR = ${SYSTEM_TMP_DIR:-${APP_DIR}/tmp}
    ```

    See [shell variable expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html "Shell Variable Expansion") for `:-` and `:=` usage.
- Load and use your env variables in PHP script

    ```
