Skip to content
Class for storing and reading environment variables from .env files stored in document root.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests/unit
.editorconfig
.gitignore
LICENSE.md
README.md
VERSIONLOG.md
composer.json
composer.lock
phpunit.xml

README.md

phpenv

Class for storing and reading environment variables from ".env" file.

Installation

To install the package using composer run composer require codebot/phpenv:1.0.*

Usage

You need to create the ".env" file in your project root and define your environment variables there.
Project root is the directory returned by $_SERVER['DOCUMENT_ROOT'] variable.
If you want to store the .env file somewhere else, you can pass the full path of your .env file as a first argument of getInstance() method, e.g. Env\Core\Env::getInstance( '/path/to/.env' ).

Example of the .env file:

# Test .env file
APP_NAME=The Phpenv Package
APP_ENV=local

Example of the usage:

$env = Env\Env::getInstance();

$env->get('APP_ENV');
You can’t perform that action at this time.