william-costa / dot-env
A simple library for managing environment variables in PHP.
Installs: 3 600
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.0
README
A simple library for managing environment variables in PHP.
Usage
To use this library, simply create a .env
file at the root of the project, following the model below (one variable per line):
DB_HOST=localhost
DB_USER=root
DB_PASS=pass
DB_NAME=database
DB_PORT=3307
<?php require 'vendor/autoload.php'; //LOAD ENVIRONMENT VARS FROM FILE ON ROOT WilliamCosta\DotEnv\Environment::load(__DIR__); //GET ENVIRONMENT VAR echo getenv('DB_HOST');
Requirements
This library needs PHP 7.0 or greater.