https://github.com/hakobyansen/phpenv
Class for storing and reading environment variables from .env files stored in document root.
https://github.com/hakobyansen/phpenv
Last synced: 10 months ago
JSON representation
Class for storing and reading environment variables from .env files stored in document root.
- Host: GitHub
- URL: https://github.com/hakobyansen/phpenv
- Owner: hakobyansen
- License: mit
- Created: 2019-02-09T01:27:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-19T17:57:56.000Z (over 5 years ago)
- Last Synced: 2025-03-16T04:21:18.765Z (about 1 year ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# phpenv
Class for storing and reading environment variables from ".env" file.
## Installation
To install the package using composer run `composer require codebot/phpenv:1.0.*`
## Usage
You need to create the ".env" file in your project root and define your environment variables there.
Project root is the directory returned by `$_SERVER['DOCUMENT_ROOT']` variable.
If you want to store the .env file somewhere else, you can pass the full path of your .env file as a first argument of `getInstance()` method, e.g. `Env\Core\Env::getInstance( '/path/to/.env' )`.
Example of the .env file:
```
# Test .env file
APP_NAME=The Phpenv Package
APP_ENV=local
```
Example of the usage:
```php
$env = Env\Env::getInstance();
$env->get('APP_ENV');
```