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.
It provides for editing environment file and manipulate them.
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.
You can pay any amount to PayPal: https://www.paypal.me/codervio?locale.x=en_US
PHP version requirements: PHP >7.0
PHP extension: mbstring
Use use Codervio\Environment\EnvParser declaration for parsing dot env files.
Use use Codervio\Environment\EnvEditor declaration for edit and manage dot env file.
A [requirements] - Requirements and auto detect encodings script automatically can check mbstring extension and automatically detects encoding types.
Example of fetching env variables and loading into global super variables like $_ENV, using function getenv() or directly using instance:
If on a file example.env contains a data:
FOO=bar
After loading instance it can be fetching a variable:
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:
(string) 'bar'Or get a result using env variables globally:
echo apache_getenv('FOO')
echo getenv('FOO')
echo $_ENV('FOO')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
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
Status of core:
| Version | State |
|---|---|
1.0 |
Release version |
PHP version above 7.0.
Quality assurance: Unit tests provided
- For loading simple ENV variables use [
example]
FOO=bar
VAREMPTY=
FOO1=foo1
WITHSPACES="with spaces"
- Lists of examples env variables: [
lists]
- Writing comments: [
comments]
# comment
# a comment #comment
## A main comment ##
FOO=bar # a commentIt is possible to parse comments variables such using:
new Envparser('main.env', true);A variable inside comment can be visible
#COM1=BAR1using command:
$envparser->getAllValues(); # to get all values
$envparser->getValue('#COM1'); # to get commented keywhich returns as array and keeps # mark:
["#COM1"]=>
string(4) "BAR1"or directly:
$envparser->getValue('#COM1');will parsing a variable
string(4) "BAR1"- Parsing export or setenv variables: [
envexports]
setenv FOO1=value # general csh case
export FOO2=value
SetEnv FOO3=value # Apache camel caseIt is possible to fetch all system variables:
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()]
- [
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] - Instance environment for creating environment file - [
Help] - Common helps and issues in a code
