Environment Context¶
Tells Drupal which environment a server runs in, like local, stage or
production, and which environments the platform knows. Sites requires it:
a site's settings can differ per environment, like Hydrion's hostname, which
is hydrion.ddev.site on a developer's machine and www.hydrion.example in
production (Hostnames per environment).
Install¶
A project of its own, drupal.org/project/environment_context:
composer require drupal/environment_context
drush en environment_context
Configure¶
Each server names its environment in settings.php, or in the
DRUPAL_ENVIRONMENT environment variable. A server that names none runs in
the default environment:
$settings['environment'] = 'stage';
The whole installation runs in that one environment (Environments). The list of environments a site type lets a setting differ by comes from a submodule: Environment Context Config Split or Environment Context Environment Indicator.
Beyond Sites, the module adds the Current environment condition to block
visibility and the environment cache context.
Last updated 2026-10-16