Debug


1Introduction

Temma provides a plugin dedicated to debugging. It enables you to collect data on the query currently being executed, and access it via a bar displayed at the bottom of pages (when the Smarty view is used).

The debugging bar provides access to the following data:

  • Log messages, so you don't have to open the log/temma.log file.
  • Session variables, GET variables, cookies and template variables.
  • Constants: contents of super-global $_SERVER and environment variables.
  • Configuration.
  • Telemetry, i.e. the tree structure of function calls and their execution times.

2Configuration

2.1Activation

To activate the plugin, simply declare it as a preplugin in the etc/temma.php configuration file:

<?php

return [
    'plugins' => [
        '_pre' => [
             '\Temma\Plugins\Debug'
        ]
    ]
];

Please note!

This plugin must only be activated on a development workstation, and never on production servers.

We therefore strongly advise you to add it only to the etc/temma.dev.php configuration file, rather than to the main etc/temma.php file. This will ensure that the plugin is only activated on machines where the ENVIRONMENT variable is set to dev (see configuration by platform documentation).

Use the _pre__prepend key to make the plugin the first in the list.

Example of a etc/temma.dev.php file:

<?php

return [
    'plugins' => [
        '_pre__prepend' => [
             '\Temma\Plugins\Debug'
        ]
    ]
];

For your information, the plugin will register itself as a post-plugin. But you must not add it to the configuration as a post-plugin, otherwise it will run twice, causing malfunctions.


2.2Disabling features

Setting up the pre-plugin will activate all debugging functions.
However, it is possible to enable or disable individual features. This can be useful for saving memory during query execution. To do this, you need to define the x-debug extended configuration:

<?php

return [
    'x-debug' => [
        // to disable the display of the debugging bar,
        // without disabling data collection
        'showBar'       => false,
        // to disable the collection and display of log messages
        'showLogs'      => false,
        // to disable the display of variables
        'showVariables' => false,
        // to disable display of constants ($_SERVER and environment)
        'showConstants' => false,
        // to disable configuration display
        'showConfig'    => false,
        // to disable telemetry
        'showTelemetry' => false,
    ]
];

3Telemetry

Telemetry allows you to view the tree structure of function calls during query execution, along with the execution time of each function.

This tool is based on PHP's register_tick_function and debug_backtrace functions. Unfortunately, these functions cannot guarantee 100% accurate retrieval.
The telemetry offered by Temma should therefore be regarded as an indicative but not exhaustive tool.

If you need complete and accurate telemetry, you can turn to tools such as OpenTelemetry, Xdebug or Blackfire.