Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/commandstring/env
A singleton class used for storing environment variables
https://github.com/commandstring/env
env environment environment-variables php php8
Last synced: about 1 month ago
JSON representation
A singleton class used for storing environment variables
- Host: GitHub
- URL: https://github.com/commandstring/env
- Owner: CommandString
- License: mit
- Created: 2022-12-19T19:09:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-15T15:56:34.000Z (over 1 year ago)
- Last Synced: 2024-04-18T02:22:12.398Z (7 months ago)
- Topics: env, environment, environment-variables, php, php8
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# commandstring/env #
A singleton class used for storing environment variables# Requirements
* PHP 8.1
* Composer# Creating with JSON file
## /env.json
```json
{
"mysql": {
"username": "root",
"password": "password",
"host": "127.0.0.1",
"port": 3306
}
}
```## /index.php
```php
Env::createWithJsonFile(__DIR__."/env.json");
```# Creating with an array
```php
Env::createFromArray(["hello" => "world"]);
```
### Note that nested arrays will be converted into an stdClass# Getting / Setting variables
```php
Env::get("property");
Env::get()->property;Env::get()->property = "value";
```