reagordi / env
Loads environment variables from `.env` to `env()`, `$_ENV` and `$_SERVER` automagically.
Fund package maintenance!
Opencollective
reagordi
Requires
- php: ^8.2
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- maglnet/composer-require-checker: ^4.7
- phpunit/phpunit: ^10.5
- rector/rector: ^1.0.3
- roave/infection-static-analysis-plugin: ^1.34
- spatie/phpunit-watcher: ^1.23
- vimeo/psalm: ^5.20
This package is auto-updated.
Last update: 2024-12-10 02:41:46 UTC
README
Reagordi Package Env
Loads environment variables from .env
to env()
, $_ENV
and $_SERVER
automagically.
Requirements
- PHP 8.2 or higher.
Installation
The package could be installed with composer:
composer require reagordi/env
General usage
You can then load .env
in your application with:
(Dotenv\Dotenv::createImmutable(__DIR__))->load();
You can get environment variables in the following ways:
$s3_bucket = env('S3_BUCKET', 'default'); $s3_bucket = getenv('S3_BUCKET'); $s3_bucket = $_ENV['S3_BUCKET']; $s3_bucket = $_SERVER['S3_BUCKET'];
Testing
Unit testing
The package is tested with PHPUnit. To run tests:
./vendor/bin/phpunit
Mutation testing
The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:
./vendor/bin/roave-infection-static-analysis-plugin
Static analysis
The code is statically analyzed with Psalm. To run static analysis:
./vendor/bin/psalm
Code style
Use Rector to make codebase follow some specific rules or use either newest or any specific version of PHP:
./vendor/bin/rector
Dependencies
Use ComposerRequireChecker to detect transitive Composer dependencies.
License
The Reagordi Package Env is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Reagordi Group.