tnapf / env
This package is abandoned and no longer maintained.
No replacement package was suggested.
A environment package for PHP
v1.2.1
2023-07-01 04:48 UTC
Requires
- php: >=8.1
Requires (Dev)
- ergebnis/composer-normalize: ^2.31
- fakerphp/faker: ^1.21
- friendsofphp/php-cs-fixer: ^3.16
- jetbrains/phpstorm-attributes: ^1.0
- phpunit/phpunit: ^10.1
- roave/security-advisories: dev-latest
- xheaven/composer-git-hooks: ^3.0
README
A package for handling environment variables in a simple way.
Installation
composer require tnapf/env
Usage
Creating without .env
use Tnapf\Env\Env; $env = new Env(); $env->devMode = true; // or $env['devMode'] = true; #################################### # Somewhere else in the script # #################################### Env::get()->devMode; // true // or Env::get()['devMode']; // true
Creating with .env file
use Tnapf\Env\Env; $env = Env::createFromFile(__DIR__ . '/.env');
Creating with string .env
use Tnapf\Env\Env; $env = Env::createFromString('devMode=true');
Getting autocomplete
Create a class that extends Tnapf\Env and add PHP DocBlocks for the properties.
use Tnapf\Env\Env as TnapfEnv; /** * @property bool $devMode * @property string $databaseHost * @property string $databaseUser * @property string $databasePassword * @property string $databaseName */ class Env extends TnapfEnv { }
Then use this class instead of Tnapf\Env\Env