webservco / environment
A PHP component/library. Names for the environments an application runs in: development, testing, staging and production.
v2.3.0
2026-10-11 16:34 UTC
Requires
- php: ^8.4
Requires (Dev)
- pds/skeleton: ^1
- phan/phan: ^6
- php-parallel-lint/php-console-highlighter: ^1
- php-parallel-lint/php-parallel-lint: ^1
- phpmd/phpmd: ^3
- phpstan/phpstan: ^2
- phpstan/phpstan-deprecation-rules: ^2
- phpstan/phpstan-phpunit: ^2
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpunit: ^13
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^4
- vimeo/psalm: ^6
- webservco/coding-standards: ^2
- webservco/component-common: ^2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP component/library. Please see webservco/sandbox for an example project using these types of components.
Names for the environments an application runs in: development, testing, staging and production.
Installation
composer require webservco/environment
Usage
Store the environment name in the configuration and compare it with the constants. The ErrorController in the webservco/sandbox project uses this to decide how much error detail to show.
use WebServCo\Environment\Contract\EnvironmentInterface; // \WebServCo\Configuration\Contract\ConfigurationGetterInterface $showErrorDetails = match ($configurationGetter->getString('ENVIRONMENT')) { EnvironmentInterface::ENVIRONMENT_DEVELOPMENT, EnvironmentInterface::ENVIRONMENT_TESTING => true, EnvironmentInterface::ENVIRONMENT_STAGING, EnvironmentInterface::ENVIRONMENT_PRODUCTION => false, };
Contracts
| Interface | Implementation | Purpose |
|---|---|---|
Contract\EnvironmentInterface |
none (constants only) | ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_TESTING, ENVIRONMENT_STAGING, ENVIRONMENT_PRODUCTION. |
Namespaces are relative to WebServCo\Environment\.
Configuration
[General] ENVIRONMENT = development
Development
# Start project. ddev start # Install dependencies. ddev c u # Run all validations. ddev c c # Run unit tests. ddev c test:dox