A plugin for Craft CMS 3.x to help distinguish your Craft environments ...so you don't forget where you are.
Switch branches/tags
Nothing to show
Latest commit 5830dd9 Dec 31, 2017
michaelrog Attached the label rendering logic to a later (post-plugin-initializa…
…tion) event, and removed our Twig extension in favor of a simple global pass-through to the Label service.

This makes a bit more functionality accessible to templates, and it prevents our plugin from trying to use Twig [to render the label text] before other plugins have had a chance to initialize. (If another plugin tried to register a Twig extension after we had already used Twig to render our template, there'd be collisions and error messages and weeping and gnashing of teeth.)

Updated version to 3.1.1.


Environment Label

...so you don't forget where you are.

A Top Shelf Craft creation
in collaboration with Kind

— Based on the original LabelEnvironment plugin by Tom Davies


The Environment Label plugin adds a nice coloured banner to your CraftCMS control panel so you'll never forget what environment you're using.

The colors and text of the environment label are configurable via the plugin config file.



Visit the Plugin Store in your Craft control panel, search for Environment Label, and click to Install the plugin.


By default, the environment label will pull in the value of Craft's CRAFT_ENVIRONMENT constant, which is set to the current hostname unless you override it.

(In other words, out of the box, you get a red banner with white text that alerts you to the current hostname.)

You can use a plugin config file to tweak the appearance and text of the environment label for each installation.

Simply add an environment-label.php file to your config directory.

(There is a sample plugin config included in the plugin files - config/environment-label.php - which you can copy and use as a starter.


return [
    'showLabel' => true,
    'labelText' => CRAFT_ENVIRONMENT,
    'prefix' => null,
    'suffix' => null,
    'labelColor' => '#cc5643',
    'textColor' => '#ffffff',

I suggest referencing PHP environment variables, rather than using hard-coded values, to make your configuration more consistently maintainable.

I also highly recommend using the PHP dot-env package to easily set and deploy environment variables across your installations. (The Craft starter project) ships with dot-env included.)

For example, your environment-label.php config file might use environment variables set by the server:


return [
    'showLabel' => getenv('CRAFT_ENV_SHOW_LABEL'),
    'labelText' => getenv('CRAFT_ENV_LABEL_TEXT'),

For added flexibility, the full text of the label will be rendered as a Twig template, so you can also include template variables if you want:


return [
    'suffixText' => " // {{ currentUser }}",

Changing Settings in the Control Panel

You can also make basic changes to the text and appearance of the environment label via the plugin Settings page.


This is provided as a convenience for easily testing out the plugin, but for full customizability, you should use a plugin config file as described above.

(Settings specified in the plugin config file will override any changes made via the Settings page in the control panel.)

Twig template globals

Environment Label makes its properties available via a Twig template global variable, so you can create your own environment label rendering in your public templates:

{{ environmentLabel.renderedText }}
{{ environmentLabel.labelColor }}
{{ environmentLabel.textColor }}

JavaScript globals

Environment Label also makes its properties available as JS globals on each authenticated CP page.


What are the system requirements?

Craft 3.0+ and PHP 7.0+

I've found a bug.

No you haven't.

Yes, I believe I have.

Well, alright. Please open a GitHub Issue, and if you're feeling ambitious, submit a PR to the 3.x.dev branch.