commandstring / env
Installs: 80
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/commandstring/env
Requires
- commandstring/utils: ^1.1
README
A singleton class used for storing environment variables
Requirements
- PHP 8.1
- Composer
Creating with JSON file
/env.json
{ "mysql": { "username": "root", "password": "password", "host": "127.0.0.1", "port": 3306 } }
/index.php
Env::createWithJsonFile(__DIR__."/env.json");
Creating with an array
Env::createFromArray(["hello" => "world"]);
Note that nested arrays will be converted into an stdClass
Getting / Setting variables
Env::get("property"); Env::get()->property; Env::get()->property = "value";