Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 118 | All time: 9,529 This week: 560 |
Version | License | PHP version | Categories | |||
environ 1.0 | Custom (specified... | 5 | PHP 5, Configuration, Parsers |
Description | Author | |
This class can load and initialized PHP environment variables. |
PHP environment loader with the power of the ini syntax and array support
![](environ.jpg?raw=true)
composer require melbahja/environ
Environ has no effect to the php runtime ini configuration, environ only takes env variables from ini file and load them
path/to/your/project/.env
; set a var
APP_MODE = "dev"
; array
[DATABASE]
HOST = '127.0.0.1'
USERNAME = 'root'
PASSWORD = null
YourScript.php
require 'vendor/autoload.php';
use Melbahja\Environ\Environ;
// environ looking for .env or env.ini file in your directory
Environ::load('path/to/your/project');
var_dump(Environ::get('APP_MODE')); // string
var_dump(Environ::get('DATABASE')); // array
var_dump($_ENV['DATABASE']); // array
# if you want a helper
function env(string $var, $default = null)
{
return \Melbahja\Environ\Environ::get($var, $default);
}
Environ::load(string $directory): bool
Environ::get(string $var, $default = null): mixed
Environ::set(string $var, $value): bool
# Example: Environ::is('apache'), Environ::is('cli')
Environ::is(string $sapi): bool
MIT Copyright (c) 2018 Mohamed Elbahja
Files (11) |
File | Role | Description | ||
---|---|---|---|---|
src (1 file, 1 directory) | ||||
tests (2 files, 1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
environ.jpg | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (11) | / | tests |
File | Role | Description | ||
---|---|---|---|---|
directory (1 file) | ||||
.env | Data | Auxiliary data | ||
EnvironTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.