Environment Indicator 

Extension key

typo3_environment_indicator

Package name

konradmichalik/typo3-environment-indicator

Version

1.1

Language

en

Author

Konrad Michalik & contributors

License

This extension documentation is published under the CC BY-NC-SA 4.0 (Creative Commons) license.


This extension provides several features to show an environment indicator in the TYPO3 frontend and backend.


Introduction 

A quick overview about the main features provided by this extension.

Installation 

Instructions on how to install this extension and which TYPO3 and PHP versions are currently supported.

Configuration 

Learn how to configure the extension in various ways. This includes extension configuration and the usage of the configuration utility.

Developer corner 

A quick overview of the possibilities for extending the extension

Introduction 

What does it do? 

This extension provides several features to show an environment indicator in the TYPO3 frontend and backend.

Features 

  • Frontend Hint: Adds an informative hint to the frontend showing the website title and the current application context.
Frontend Hint Preview
  • Backend toolbar: item: Adds an informative item with the current application context to the backend toolbar.
Backend Toolbar Item Preview
  • Modified favicon: Modify the favicon for frontend and backend based on the original favicon, the current application context and your configuration.
Favicon Preview

Support 

There are several ways to get support for this extension:

License 

This extension is licensed under GNU General Public License 2.0 (or later).

Installation 

Requirements 

  • PHP 8.1 - 8.4
  • TYPO3 11.5 LTS - 13.4 LTS
  • ImageDriver: GD, Imagick or libvips

Installation 

Require the extension via Composer (recommended):

composer require konradmichalik/typo3-environment-indicator
Copied!

Or download it from the TYPO3 extension repository.

Configuration 

Include the static TypoScript template "Environment Indicator" or directly import it in your sitepackage (only necessary for the frontend Hint):

Configuration/TypoScript/setup.typoscript
@import 'EXT:typo3_environment_indicator/Configuration/TypoScript/setup.typoscript'
Copied!

Configuration 

The extension is ready to use without any further setup.

You can also adapt the extension to your needs, switch single features on and off and influence the presentation of the indicators.

Learn what configuration options are available on the following pages:

Extension configuration 

  1. Go to Admin Tools > Settings > Extension Configuration
  2. Choose typo3_environment_indicator

The extension currently provides the following configuration options:

General 

general.imageDriver

general.imageDriver
Type
option
Default
"gd"

Intervention Image supports "GD Library", "Imagick" and "libvips" to process images internally. You may choose one of them according to your PHP configuration. Options are "gd", "imagick" and "vips".

Frontend 

frontend.favicon

frontend.favicon
Type
boolean
Default
1

Enable the favicon generation in frontend context

frontend.context

frontend.context
Type
boolean
Default
1

Enable the context frontend hint

Backend 

backend.favicon

backend.favicon
Type
boolean
Default
1

Enable the favicon generation in backend context

backend.context

backend.context
Type
boolean
Default
1

Enable the context item within the backend toolbar

backend.contextProduction

backend.contextProduction
Type
boolean
Default
1

Enable the backend toolbar item also in production context

backend.contextProductionUserGroups

backend.contextProductionUserGroups
Type
string
Default
1

Restrict the backend user groups that are shown the toolbar item in the production context (comma separated list of group ids)

Frontend Hint 

The frontend hint will show the current application context information and the website title as clickable note in the upper right corner.

Frontend hint

Frontend hint

You can adjust the color of the hint in your ext_localconf.php:

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    frontendHintConfiguration: [
        'color' => '#bd593a',
    ],
);
Copied!

Additional optional configuration keys:

  • text (string): The text of the hint. Default is the website title.
  • position (string): The position of the frontend hint. Default is top left. Possible values are bottom left,

bottom right, top left, top right.

Backend toolbar item 

The backend toolbar item will show the current project version and application context.

Backend toolbar item

Backend toolbar item

You can adjust the color of the toolbar item in your ext_localconf.php:

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    backendToolbarConfiguration: [
        'color' => '#bd593a',
    ]
);
Copied!

Additional optional configuration keys:

  • text (string): The text of the toolbar item. Default is the application context.
  • icon (string): The icon of the toolbar item. Default is information-application-context.
  • index (int): The positioning index of the toolbar item. Default is 0.

Favicon 

The favicon of the frontend or backend context will be modified regarding the application context and the associated configuration.

Favicon Example

Favicon Example

local
 
depth

2

Frontend 

For the frontend, the original favicon will either be fetched from the typoscript configuration page.shortcutIcon (see typoscript reference) or can be handled by your own fluid template via the FaviconViewHelper:

Custom fluid template
<html xmlns:env="http://typo3.org/ns/KonradMichalik/Typo3EnvironmentIndicator/ViewHelpers"
    data-namespace-typo3-fluid="true">

{f:uri.resource(path:'EXT:your_extension/Resources/Public/Favicon/favicon.png') -> env:favicon()}
{env:favicon(favicon:'EXT:your_extension/Resources/Public/Favicon/favicon.png')}
Copied!

Backend 

For the backend, the favicon will be fetched by the extension configuration of $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['backend']['backendFavicon'].

Favicon Examples

Favicon Examples

Modifiers 

The favicon modification configuration can be found in $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['typo3_environment_indicator'].

Add a configured favicon modifier to the desired application context (e.g. Testing) in your ext_localconf.php:

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Testing',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\TextModifier::class =>
        [
            'text' => 'TEST',
            'color' => '#f39c12',
            'stroke' => [
                'color' => '#ffffff',
                'width' => 3,
            ],
        ]
    ],
);
Copied!
Favicon Modifier Example

The modifiers will be executed one after the other. You can combine them if you want.

The following modifier classes are available:

TextModifier 

This is the default modifier if no own configuration is set.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\TextModifier::class =>
        [
            'text' => 'DEV',
            'color' => '#bd593a',
            'stroke' => [
                'color' => '#ffffff',
                'width' => 3,
            ],
        ]
    ],
);
Copied!
Favicon TextModifier Example

Additional optional configuration keys:

  • font (string): The font file path for the text. Default is

EXT:typo3_environment_indicator/Resources/Public/Fonts/OpenSans-Bold.ttf. - position (string): The position of the text. Default is bottom. Possible values are bottom, top.

TriangleModifier 

Adds a triangle indicator to the favicon.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\TriangleModifier::class =>
        [
            'color' => '#bd593a',
        ]
    ],
);
Copied!
Favicon TriangleModifier Example

Additional optional configuration keys:

  • size (float): The percentage size of the triangle. Default is 0.7.
  • position (string): The position of the triangle. Default is bottom right. Possible values are bottom left,

bottom right, top left, top right.

CircleModifier 

Adds a circle indicator to the favicon.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\CircleModifier::class =>
        [
            'color' => '#bd593a',
        ]
    ],
);
Copied!
Favicon CircleModifier Example

Additional optional configuration keys:

  • size (float): The percentage size of the circle. Default is 0.4.
  • position (string): The position of the circle. Default is bottom right. Possible values are bottom left,

bottom right, top left, top right. - padding (float): The percentage padding of the circle. Default is 0.1.

FrameModifier 

Adds a frame around the favicon.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\FrameModifier::class =>
        [
            'color' => '#bd593a',
        ]
    ],
);
Copied!
Favicon FrameModifier Example

Additional optional configuration keys:

  • borderSize (float): The border size of the frame. Default is 5.

ReplaceModifier 

Replace the original favicon with a custom one regarding the application context.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\ReplaceModifier::class =>
        [
            'path' => 'EXT:sitepackage/Resources/Public/Icons/favicon.png',
        ]
    ],
);
Copied!
Favicon ReplaceModifier Example

OverlayModifier 

Overlay an additional image to the original favicon regarding the application context.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\OverlayModifier::class =>
        [
            'path' => 'EXT:sitepackage/Resources/Public/Icons/favicon.png',
        ]
    ],
);
Copied!
Favicon OverlayModifier Example

Additional optional configuration keys:

  • size (float): The percentage size of the overlay. Default is 0.5.
  • position (string): The position of the overlay. Default is bottom right. Possible values are bottom left,

bottom right, top left, top right. - padding (float): The percentage padding of the overlay. Default is 0.1.

ColorizeModifier 

Overlay an additional image to the original favicon regarding the application context.

ext_localconf.php
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\ColorizeModifier::class =>
        [
            'color' => '#039BE5',
        ]
    ],
);
Copied!
Favicon ColorizeModifier Example

Additional optional configuration keys:

  • opacity (float): Controls the opacity of the colorization. Default is 1.
  • brightness (integer): Controls the brightness of the colorization. Possible values are from -100 to 100.
  • contrast (integer): Controls the contrast of the colorization. Possible values are from -100 to 100.

Developer corner 

Some kinds of the environment indicators are configurable or can be extended with custom implementations. This section provides an insight into which development options are available and how these can be integrated into the generation process.

Custom modifiers 

The predefined modifiers are not enough for your use case? No problem! You can easily write your own.

Implement your own image modifier by extending the AbstractModifier class and implementing the ModifierInterface method.

Classes/Image/CustomModifier.php
<?php

namespace Vendor\YourExt\Image;

use Intervention\Image\Geometry\Factories\RectangleFactory;
use Intervention\Image\Interfaces\ImageInterface;

class CustomModifier extends AbstractModifier implements ModifierInterface {

    public function modify(ImageInterface &$image): void
    {
        // Modify the image
    }

    public function getRequiredConfigurationKeys(): array
    {
        // Return the required configuration keys
    }
}
Copied!

See the Intervention Image documentation for more information about image manipulation.

Configuration Utility 

Generally the whole configuration can be found in $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['typo3_environment_indicator']. You can/should use the ConfigurationUtility::configByContext() to easily add necessary configuration for the environment indicator.

ext_localconf.php
// Add a colorized favicon modifier, add a colorful backend toolbar item and unset the frontend hint for the Development context
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility::configByContext(
    applicationContext: 'Development',
    faviconModifierConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\ColorizeModifier::class =>
        [
            'color' => '#039BE5',
        ]
    ],
    faviconModifierFrontendConfiguration: [
        \KonradMichalik\Typo3EnvironmentIndicator\Image\ColorizeModifier::class =>
        [
            'opacity' => 0.5 // Change just the opacity for the frontend favicon configuration
        ]
    ],
    frontendHintConfiguration: null, // Unset frontend hint for Development context
    backendToolbarConfiguration: [
        'color' => '#039BE5',
    ]
);
Copied!
class ConfigurationUtility
Fully qualified name
\KonradMichalik\Typo3EnvironmentIndicator\Utility\ConfigurationUtility

Utility class to easily configure the environment indicators.

configByContext ( $applicationContext, $frontendHintConfiguration = [], $backendToolbarConfiguration = [], $faviconModifierConfiguration = [], $faviconModifierFrontendConfiguration = [], $faviconModifierBackendConfiguration = [])

Simple function to update the status of a record.

param string $applicationContext

Name of the TYPO3 application context.

param array|null $frontendHintConfiguration

Configuration for the frontend hint. Set to null to unset the configuration.

param array|null $backendToolbarConfiguration

Configuration for the backend toolbar item. Set to null to unset the configuration.

param array|null $faviconModifierConfiguration

Configuration for the favicon modification. This configuration applies to frontend and backend. Set to null to unset the configuration.

param array|null $faviconModifierFrontendConfiguration

Frontend configuration for the favicon modification. Set to null to unset the configuration.

param array|null $faviconModifierBackendConfiguration

Frontend configuration for the favicon modification. Set to null to unset the configuration.

returntype

void