2017 © Pedro Peláez
 

library env

Set and use environment from JSON file.

image

kijtra/env

Set and use environment from JSON file.

  • Friday, November 11, 2016
  • by kijtra
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

kijtra/env

Build Status Coverage Status Software License Total Downloads, (*1)

Set and use environment from JSON file. Inspired vlucas/phpdotenv.
:warning: JSON FILE ONLY, (*2)

Support PHP >= 5.3, (*3)

Install

Using Composer, (*4)

composer.phar require kijtra/env

SetUp

<?php
// Autoload only
require_once '/path/to/vendor/autoload.php';

Function usage

JSON example, (*5)

{
    "FOO": "Foo value",
    "BAR": {
        "BAR-one": "Bar One value",
        "BAR-two": "Bar Two value"
    }
}

Usage, (*6)

<?php
// Load JSON file
env(array('/path/to/example.json'));

// Or multiple files
// env(array('/path/to/example.json', '../../other.json'));

// Basic use
echo env('FOO'); // "Foo value"

// You can use dot separated name
// (better than vlucas/phpdotenv)
echo env('BAR.BAR-one'); // "Bar One value"

// Get all environments
$all = env();

// If you need clear all environment, set PHP_EOL
env(PHP_EOL);

JSON format

Simple, (*7)

{
    "FOO": "Foo value",
    "BAR": "Bar value"
}

Nested, (*8)

{
    "FOO": {
        "FOO-one": "Foo One value",
        "FOO-two": "Foo Two value"
    },
    "BAR": [
        "Bar One value",
        "Bar Two value"
    ]
}

Placeholder, (*9)

{
    "FOO": "Foo value",
    "BAR": "{FOO} after Bar value"
}

And reverse replacing placeholder
(better than vlucas/phpdotenv), (*10)

{
    "FOO": "{BAR} before Foo value",
    "BAR": "Bar value"
}

Nested placeholder
(better than vlucas/phpdotenv), (*11)

{
    "FOO": {
        "FOO-one": "Foo One value",
        "FOO-two": "Foo Two value"
    },
    "BAR": "{FOO.FOO-two} and Bar value"
}

Class version

Function env() is alias of this class., (*12)

<?php
use \kijtra\Env;

// Load JSON file
Env::file('/path/to/env.json');

// Or multiple files
Env::file(array('/path/to/env.json', '../other.json'));
Env::file('/path/to/env.json', '../other.json');

// Basic use
echo Env::get('FOO');

// You can use dot separated name
echo Env::get('BAR.BAR-one');

// Get all environments
$all = Env::all();

// Clear all environment
 Env::clear();

TODO

JavaScript(node.js) version, (*13)

The Versions

11/11 2016

dev-master

9999999-dev

Set and use environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env

16/09 2016

0.3.2

0.3.2.0

Set and use environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env

16/09 2016

0.3.1

0.3.1.0

Simple function Environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env

14/09 2016

0.3.0

0.3.0.0

Simple function Environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env

12/09 2016

0.2.0

0.2.0.0

Simple function Environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env

12/09 2016

0.1.0

0.1.0.0

Simple function Environment from JSON file.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

environment env