PHPackages                             m1/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. m1/env

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

m1/env
======

Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.

2.2.0(6y ago)6412.0M—1.5%9[2 issues](https://github.com/m1/Env/issues)[1 PRs](https://github.com/m1/Env/pulls)19MITPHPPHP &gt;=5.3.0

Since Dec 13Pushed 4y ago6 watchersCompare

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

READMEChangelog (10)Dependencies (3)Versions (12)Used By (19)

Env
===

[](#env)

[![Author](https://camo.githubusercontent.com/ed167a3f87bb811a7e157913a2461cc647ef51ca73a97b674a7805f54b8caa70/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d696c657363726f78666f72642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/milescroxford)[![Latest Version on Packagist](https://camo.githubusercontent.com/34a89d0d1997ad00b6a5835631735adb51d444892ec84b4378a6d09129db7648/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d312f456e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1/Env)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/43740365cb756bc2bbaa39cdc4766fc946ff3864dc9068fe6d2ea4394b876f9b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d312f456e762f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/m1/Env)[![Coverage Status](https://camo.githubusercontent.com/c1bec67dc55619d398f2af8f002f497b402aab6fc9dfb638ca297ee8f5b04824/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d312f456e762e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/m1/Env/code-structure)[![Quality Score](https://camo.githubusercontent.com/821c5a04063d865a0d6a5a2d966219217038054693975397bcf24a6572600a48/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d312f456e762e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/m1/Env)[![Downloads](https://camo.githubusercontent.com/67e5aa6db3eb78978762bf2347c0d73fb5f4ab7aab8c76996ced49813bb1b8e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d312f456e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1/Env)[![StyleCI](https://camo.githubusercontent.com/f8511e620ee64eaebe6b6364cac5f3753a9a3579e244e410e0bfcd36a08f8244/68747470733a2f2f7374796c6563692e696f2f7265706f732f34373933353133332f736869656c64)](https://styleci.io/repos/47935133)

[![Sensio badge](https://camo.githubusercontent.com/f21defe5b72ef75c00e97c7b77a9708e94ed5156bdb55b8c0cd2d454cc30644a/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31666238636261622d663631312d343562352d386134352d3031313365343333656162372f6269672e706e67)](https://insight.sensiolabs.com/projects/1fb8cbab-f611-45b5-8a45-0113e433eab7)

Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.

- [Why?](#why)
- [Requirements](#requirements)
- [Install](#install)
- [Usage](#usage)
    - [Basic](#basic)
    - [Context variables](#context)
    - [Syntax](#syntax)
        - [Assignment](#assignment)
        - [Strings](#strings)
        - [Numbers](#numbers)
        - [Booleans](#booleans)
        - [Null](#null)
        - [Variables](#variables)
            - [Default Value/Assignment](#parameter-expansion)
        - [Comments](#comments)
    - [.env example](#env-example)
- [Notes](#notes)
    - [Source](#source)
- [Other library comparisons](#other-library-comparisons)
- [Todo](#todo)
- [Change log](#change-log)
- [Testing](#testing)
- [Contributing](#Contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Why?
----

[](#why)

Env aims to bring a unified parser for env together for PHP rather than having a few incomplete or buggy parsers written into other libraries. This library is not meant as a complete package for config loading like other libraries as this is out of scope for this library. If you need something like that check out [Vars](http://github.com/m1/Vars) which incorporates this library so you can load Env and other file types if you want, or checkout [PHP Dotenv](https://github.com/josegonzalez/php-dotenv)if you only need .env parsing

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

[](#requirements)

Env requires PHP version `5.3+` - supported and tested on `5.3`, `5.4`, `5.5`, `5.6`, `7` and `hhvm`.

Install
-------

[](#install)

Via Composer

```
$ composer require m1/env
```

Usage
-----

[](#usage)

### Basic

[](#basic)

test.env

```
TEST_1 = VALUE
```

example.php

```
