diff --git a/doc/config.rst b/doc/config.rst index 044576238f..33ca40d952 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -3433,6 +3433,18 @@ Developer These settings might have huge effect on performance or security. +.. config:option:: $cfg['environment'] + + :type: string + :default: ``'production'`` + + Sets the working environment. + + This only needs to be changed when you are developing phpMyAdmin itself. + The ``development`` mode may display debug information in some places. + + Possible values are ``'production'`` or ``'development'``. + .. config:option:: $cfg['DBG'] :type: array diff --git a/libraries/classes/Template.php b/libraries/classes/Template.php index f76d818da7..80fddd4b0c 100644 --- a/libraries/classes/Template.php +++ b/libraries/classes/Template.php @@ -26,6 +26,7 @@ use Twig\Environment; use Twig\Error\LoaderError; use Twig\Error\RuntimeError; use Twig\Error\SyntaxError; +use Twig\Extension\DebugExtension; use Twig\Loader\FilesystemLoader; use Twig_Error_Loader; use Twig_Error_Runtime; @@ -56,6 +57,8 @@ class Template */ public function __construct() { + global $cfg; + /** @var Config $config */ $config = $GLOBALS['PMA_Config']; if (static::$twig === null) { @@ -68,8 +71,11 @@ class Template $twig = new Environment($loader, [ 'auto_reload' => true, 'cache' => $cache_dir, - 'debug' => false, ]); + if ($cfg['environment'] === 'development') { + $twig->enableDebug(); + $twig->addExtension(new DebugExtension()); + } $twig->addExtension(new CoreExtension()); $twig->addExtension(new I18nExtension()); $twig->addExtension(new MessageExtension()); diff --git a/libraries/config.default.php b/libraries/config.default.php index ecc24e592f..485ac97076 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2858,6 +2858,15 @@ $cfg['DBG']['demo'] = false; */ $cfg['DBG']['simple2fa'] = false; +/** + * Sets the working environment + * + * This only needs to be changed when you are developing phpMyAdmin itself. + * The development mode may display debug information in some places. + * + * Possible values are 'production' or 'development' + */ +$cfg['environment'] = 'production'; /******************************************************************************* * MySQL settings