PHPackages                             hashbang/envfile - 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. hashbang/envfile

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

hashbang/envfile
================

PHP implementation of the NodeJS envfile system

v1.1.0(11y ago)029MITPHPPHP &gt;=5.0.0

Since Jun 12Pushed 11y ago2 watchersCompare

[ Source](https://github.com/MomsFriendlyDevCo/php-envfile)[ Packagist](https://packagist.org/packages/hashbang/envfile)[ Docs](https://github.com/MomsFriendlyDevCo/php-envfile)[ RSS](/packages/hashbang-envfile/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

PHP-EnvFile
===========

[](#php-envfile)

PHP implementation of the [NodeJS envfile system](https://www.npmjs.org/package/envfile).

This system works by the dev placing a `.env` file in the root of a project. That file is read for various config information which is imported into scope. Its expected that that file is excluded from commits (via `.gitignore` or whatever) with every dev having their own `.env` file unique to them.

As an additional sanity measure its recommended that a `.env.example` file is placed in the same directory containing example settings. If present that file will be scanned and the variables imported into `.env` compared to make sure no settings are missing.

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

[](#installation)

Grab the `envfile.php` file and drop it into your project.

Alternatively install via Composer:

```
composer require hashbang/envfile

```

Usage
=====

[](#usage)

The .env file
-------------

[](#the-env-file)

The `.env` file is a simple key/value file in the same form as a INI file.

```
a=1
b:2
c = 3
d : 4

```

Use within PHP
--------------

[](#use-within-php)

Importing this into a PHP project is straight-forward:

```
include('envfile.php'); //
