2017 © Pedro Peláez
 

library dotenv

Advanced loading and parsing .env file in PHP-7

image

neonxp/dotenv

Advanced loading and parsing .env file in PHP-7

  • Friday, January 19, 2018
  • by NeonXP
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Dotenv

Build Status Codecov GitHub issues GitHub forks GitHub stars GitHub license, (*1)

What is it?

Small library, that automaticaly loads .env (or any other) file to applications environment., (*2)

Why not XXX?

Because this library is pretty simple, without external dependencies and highly customizable., (*3)

Installation

composer require neonxp/dotenv

Usage

Basic usage:, (*4)

use NeonXP\Dotenv\Dotenv;

$dotenv = new Dotenv();
$dotenv->load(); // You can specify file to load at first argument

print $dotenv->get('KEY', 'default') . PHP_EOL;
print $dotenv['KEY'] . PHP_EOL;
foreach ($dotenv as $key => $value) {
    print "$key = $value" . PHP_EOL;
}

.env file syntax

Here examples of syntax:, (*5)

# This is a comment

# Empty lines also ignored
export KEY1=VALUE1
KEY2 = VALUE2 # Inline comment
KEY3 = 'VALUE3 # This is not comment'
KEY4 = "VALUE4 # And this value too"
KEY5 = ${KEY1} -> ${KEY2} # Compilled from another variables

and we will get:, (*6)

[
    'KEY1' => 'VALUE1',
    'KEY2' => 'VALUE2',
    'KEY3' => 'VALUE3 # This is not comment',
    'KEY4' => 'VALUE4 # And this value too',
    'KEY5' => 'VALUE1 -> VALUE2',
]

The Versions

19/01 2018

dev-master

9999999-dev

Advanced loading and parsing .env file in PHP-7

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Alexander Kiryukhin

19/01 2018

0.0.1

0.0.1.0

Advanced loading and parsing .env file in PHP-7

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Alexander Kiryukhin