Download the PHP package ergebnis/environment-variables without Composer
On this page you can find all versions of the php package ergebnis/environment-variables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ergebnis/environment-variables
More information about ergebnis/environment-variables
Files in ergebnis/environment-variables
Package environment-variables
Short Description Provides an abstraction for environment variables.
License MIT
Homepage https://github.com/ergebnis/environment-variables
Informations about the package environment-variables
environment-variables
This project provides a composer
package with an abstraction of environment variables.
Installation
Run
Usage
This package provides the interface Ergebnis\Environment\Variables
along with the following production implementations:
Ergebnis\Environment\SystemVariables
This package also provides the following test implementations:
Ergebnis\Environment\FakeVariables
Ergebnis\Environment\ReadOnlyVariables
Ergebnis\Environment\TestVariables
Production Implementation
Ergebnis\Environment\SystemVariables
If you want to read, set, and unset environment variables in an object-oriented way in a production environment, you can use Ergebnis\Environment\SystemVariables
:
Test Implementation
Ergebnis\Environment\FakeVariables
If you want to read, set, and unset environment variables in an object-oriented way in a test environment, but do not actually want to modify system environment variables, you can use Ergebnis\Environment\FakeVariables
as a test-double:
Ergebnis\Environment\ReadOnlyVariables
If you want to read environment variables in an object-oriented way in a test environment, but neither actually want to modify system environment variables, nor allow modification by the system under test, you can use Ergebnis\Environment\ReadOnlyVariables
as a test-double:
:bulb: The ReadOnlyVariables
implementation will throw a ShouldNotBeUsed
exception when the system under tests uses any of the following methods:
set()
unset()
Ergebnis\Environment\TestVariables
If your tests depend on environment variables, you have the following challenges:
- when you modify environment variables in a test, you want to restore environment variables that have existed before the test run to their original values
- when you modify environment variables in a test that has not been backed up before, and forget to restore it, it might affect other tests
To solve this problem, you can add the @backupGlobals
annotation to your test cases when using phpunit/phpunit
, or use Ergebnis\Environment\TestVariables
:
Changelog
The maintainers of this project record notable changes to this project in a changelog.
Contributing
The maintainers of this project suggest following the contribution guide.
Code of Conduct
The maintainers of this project ask contributors to follow the code of conduct.
General Support Policy
The maintainers of this project provide limited support.
You can support the maintenance of this project by sponsoring @localheinz or requesting an invoice for services related to this project.
PHP Version Support Policy
This project supports PHP versions with active and security support.
The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.
Security Policy
This project has a security policy.
License
This project uses the MIT license.
Social
Follow @localheinz and @ergebnis on Twitter.