jainilnagar / env-beacon
A lightweight Craft CMS 4 and 5 plugin that displays a clear environment badge in the control panel and frontend.
Package info
github.com/jainilnagar/craft-env-beacon
Type:craft-plugin
pkg:composer/jainilnagar/env-beacon
Requires
- php: ^8.0.2
- craftcms/cms: ^4.0.0 || ^5.0.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
README
Env Beacon for Craft CMS
Env Beacon is a lightweight Craft CMS plugin that displays a small environment badge in the Craft control panel and, optionally, on the front-end site.
Use it to make the current environment obvious to editors, admins, and developers:
- Local
- Development
- Staging
- QA
- Production
It is intentionally simple: no database tables, no queues, no external services, and no JavaScript dependency.
Features
- Control panel badge for the current environment
- Optional front-end site badge
- Fixed bottom-right badge position
- Automatic label detection from common environment variables
- Custom environment variable mode
- Custom label mode
- Automatic colors:
- Production / Live → red
- Staging / Test / QA → amber
- Local / Dev / DDEV → blue
- Custom hex color support
- Optional status dot
- Optional hostname display
- Optional admin-only visibility
- Optional login-screen visibility
- Supports project config and
config/env-beacon.phpoverrides
Requirements
- Craft CMS 4.x or 5.x
- PHP 8.0.2 or later
Installation
You can install Env Beacon via the plugin store, or through Composer.
Composer
You can also add the package to your project using Composer and the command line.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to require the plugin, and Craft to install it:
composer require jainilnagar/env-beacon && php craft plugin/install env-beacon
Craft Plugin Store
To install Env Beacon, navigate to the Plugin Store section of your Craft control panel, search for Env Beacon.
Configuration
You can configure Env Beacon from:
Settings → Plugins → Env Beacon
You can also override settings per environment in:
config/env-beacon.php
Example:
<?php return [ '*' => [ 'source' => 'auto', 'colorMode' => 'auto', 'showOnFrontend' => true, ], 'dev' => [ 'label' => 'Local', 'source' => 'custom', 'colorMode' => 'custom', 'customColor' => '#2563eb', ], 'staging' => [ 'label' => 'Staging', 'source' => 'custom', 'colorMode' => 'custom', 'customColor' => '#d97706', ], 'production' => [ 'label' => 'Production', 'source' => 'custom', 'colorMode' => 'custom', 'customColor' => '#dc2626', 'adminsOnly' => true, ], ];
Visibility behavior
- Control panel pages show the badge when the plugin is enabled.
- Front-end pages show the badge when
showOnFrontendis enabled. - If
adminsOnlyis enabled, the badge is hidden from non-admin users. - If
showOnLoginis enabled, the login screen shows the badge even whenadminsOnlyis enabled, because no admin user is authenticated yet.
Environment label detection
When label source is set to auto, Env Beacon checks these values in order:
ENV_BEACON_LABELCRAFT_ENVIRONMENTENVIRONMENTAPP_ENVYII_ENVCRAFT_ENVIRONMENTconstantYII_ENVconstant- Craft’s
devModefallback
Suggested .env values
CRAFT_ENVIRONMENT=dev
CRAFT_ENVIRONMENT=staging
CRAFT_ENVIRONMENT=production
Or use the plugin-specific variable:
ENV_BEACON_LABEL=Staging
License
MIT