2017 © Pedro Peláez
 

library envmanager

Codervio Environment manager

image

codervio/envmanager

Codervio Environment manager

  • Tuesday, April 17, 2018
  • by marinsagovac
  • Repository
  • 1 Watchers
  • 0 Stars
  • 94 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 755 % Grown

The README.md

Environment manager

Join the chat at https://gitter.im/Codervio/Envmanager, (*1)

Latest Version on Packagist Build Status Total Downloads, (*2)

The Environment manager parses, populates dot environment variables from env files to super global $_ENV variable, apache and getenv function. It supports for checking variables and fetching system only variables., (*3)

It provides for editing environment file and manipulate them., (*4)

Screenshot, (*5)

Donations

Due I am working 100% alone without any helps, organizations and any others team I can be satisfy for receiving any amount of payment to improve, develop and continue building on origin idea of framework., (*6)

You can pay any amount to PayPal: https://www.paypal.me/codervio?locale.x=en_US, (*7)

Installation

  1. Installation via Composer on Packagist
  2. Installation using Git GIT clone component

Prerequisities

PHP version requirements: PHP >7.0, (*8)

PHP extension: mbstring, (*9)

Use use Codervio\Environment\EnvParser declaration for parsing dot env files., (*10)

Use use Codervio\Environment\EnvEditor declaration for edit and manage dot env file., (*11)

A [requirements] - Requirements and auto detect encodings script automatically can check mbstring extension and automatically detects encoding types., (*12)

Usage

Example of fetching env variables and loading into global super variables like $_ENV, using function getenv() or directly using instance:, (*13)

If on a file example.env contains a data:, (*14)

FOO=bar

After loading instance it can be fetching a variable:, (*15)

use Codervio\Envmanager\Envparser;

$envparser = new Envparser('.env');
$envparser->load();
$envparser->run();

$result = $parser->getValue('FOO');
var_dump($result);

Returns a result will automatically detect type of getting env variables:, (*16)

(string) 'bar'

Or get a result using env variables globally:, (*17)

    echo apache_getenv('FOO')
    echo getenv('FOO')
    echo $_ENV('FOO')

Returning a result

A result returns in following orders: - using apache_getenv() if apache service is configured internally to use only Apache environment - using getenv() that most Unix systems supports - using PHP native super globals $_ENV function, (*18)

It will automatically parse to PHP env functions and super globals so you can access via: - superglobals functions $_ENV - superglobals $_SERVER variable - using getenv() if is enabled by system - using apache_getenv() if is enabled by Apache service, (*19)

Changelog

Status of core:, (*20)

Version State
1.0 Release version

PHP version above 7.0. Quality assurance: Unit tests provided, (*21)

Table of Contents

Envparser

Common env variables

  • For loading simple ENV variables use [example]
FOO=bar
VAREMPTY=
FOO1=foo1
WITHSPACES="with spaces"

Lists examples env variables

  • Lists of examples env variables: [lists]

Comments

  • Writing comments: [comments]
# comment
# a comment #comment
## A main comment ##
FOO=bar # a comment

Comments parsing as variable (dev only, not recommeded)

It is possible to parse comments variables such using:, (*22)

 new Envparser('main.env', true);

A variable inside comment can be visible, (*23)

 #COM1=BAR1

using command:, (*24)

 $envparser->getAllValues(); # to get all values
 $envparser->getValue('#COM1'); # to get commented key

which returns as array and keeps # mark:, (*25)

  ["#COM1"]=>
  string(4) "BAR1"

or directly:, (*26)

 $envparser->getValue('#COM1');

will parsing a variable, (*27)

  string(4) "BAR1"

Parsing apache env variables or unix exports env variables

  • Parsing export or setenv variables: [envexports]
setenv FOO1=value # general csh case
export FOO2=value 
SetEnv FOO3=value # Apache camel case

Get a system only variables

It is possible to fetch all system variables:, (*28)

use Codervio\Envmanager\Envparser;

$envparser = new Envparser();
$envparser->load();
$envparser->run();

var_dump($envparser->getSystemVars());
  • For fetching single variable or just check a variable exists see [getSystemVars] and [checkSystemVar()].
  • See validation types for values in environment variables: [required()]
  • To fetch a comment from a file of specific variable use: [getComment()]

References

  • [requirements] - Requirements and auto detect encodings
  • [setEncoding()] - Manually specify encoding
  • [getEncoding()] - Detect encoding type from file
  • [checkSuperGlobalsSet()] - Check if set or get env directive for $_ENV active
  • [Envparser()] - A construct parser constructor
  • [load()] - Load an environment .env file or folder with .env files
  • [getComment()] - Get a comment from a variable of .env file
  • [getValue()] - Get a value from system environment variables and parsing variables
  • [getAllValues()] - Returns parsed environment variables internally as array
  • [getSystemVars()] - Fetch all or one system variables
  • [checkSystemVar()]- Returns boolean if system variables exists
  • [setStrictBool()] - Parse value to boolen on non-standard values such as 'y/n' or '1/0'
  • [required()] - Instance of variable validator and variable validators

EnvEditor

  • [Enveditor] - Instance environment for creating environment file
  • [Help] - Common helps and issues in a code

The Versions

17/04 2018

dev-master

9999999-dev http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

framework parser php config environment env dotenv loader .env dotenv-editor dev-tools array-env dot-env

08/03 2018

1.7

1.7.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

framework parser php config environment env dotenv loader .env dotenv-editor dev-tools array-env dot-env

05/03 2018

1.6

1.6.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

framework parser php config environment env dotenv loader .env dotenv-editor dev-tools array-env dot-env

25/02 2018

1.5

1.5.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.4

1.4.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.3

1.3.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.1.2

1.1.2.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.2

1.2.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.1.1

1.1.1.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac

23/02 2018

1.1

1.1.0.0 http://codervio.com

Codervio Environment manager

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Marin Sagovac