kaiseki / wp-env
WordPress Environment Helper
Requires
- php: ^8.2
- psr/container: ^1.1 || ^2.0
Requires (Dev)
- bnf/phpstan-psr-container: ^1.1
- kaiseki/php-coding-standard: ^1.0
- maglnet/composer-require-checker: ^4.0
- php-stubs/wordpress-stubs: ^6.2
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^11.0
- roave/security-advisories: dev-latest
- roots/wordpress-core-installer: *
- roots/wordpress-no-content: @stable
- szepeviktor/phpstan-wordpress: ^2.0
- thecodingmachine/phpstan-safe-rule: ^1.4
This package is auto-updated.
Last update: 2026-06-02 23:45:38 UTC
README
WordPress environment helper — resolve and check the current environment type.
Reads the environment from the WP_ENV constant when it's defined (and a string), otherwise falls
back to WordPress's wp_get_environment_type(). Provides typed checks (isProduction(),
isStaging(), …) in both an injectable (Environment) and a static (StaticEnvironment) flavor.
Installation
composer require kaiseki/wp-env
Requires PHP 8.2 or newer.
Usage
use Kaiseki\WordPress\Environment\Environment; $env = new Environment(); $env->get(); // e.g. 'production' $env->isProduction(); // true $env->is('staging', 'production'); // true if the env is either
The recognized values are development, local, production, and staging (the
AbstractEnvironment constants). When you can't inject a dependency, use the static variant:
use Kaiseki\WordPress\Environment\StaticEnvironment; if (StaticEnvironment::isLocal()) { // … }
Container wiring
ConfigProvider registers the interface → implementation aliases for a PSR-11 container
(laminas-style config aggregator): EnvironmentInterface → Environment and
StaticEnvironmentInterface → StaticEnvironment. Type-hint EnvironmentInterface in your
services and let the container resolve it.
Development
composer install
composer check # check-deps, cs-check, phpstan
License
MIT — see LICENSE.