Search by

webservco / environment

ariademur

A PHP component/library. Names for the environments an application runs in: development, testing, staging and production.

Package info

github.com/webservco/environment

Homepage

pkg:composer/webservco/environment

Statistics

Installs: 78

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.3.0 2026-10-11 16:34 UTC

This package is auto-updated.

Last update: 2026-10-11 16:45:39 UTC


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

License

MIT