J3.x

Allow registering callback functions for the debug console

From Joomla! Documentation

Joomla! 
3.7

Allowing extensions to register a callable function to be triggered when the debug console is rendered. This gives a hook to allow extensions to add data to the console.

API Methods[edit]

// Only register when in debug mode and the debug plugin is enabled
if (JDEBUG && JPluginHelper::isEnabled('system', 'debug'))
{
    PlgSystemDebug::addDisplayCallback('test', function () { return 'Testing new debug console feature!' });


  • PlgSystemDebug::addDisplayCallback() which takes two parameters:
    • $name is the name of the callable function, it's used as an identifier for the various markup elements and to create the language key to translate the title
    • $callable is a valid callable function (anything which passes PHP 5.4's callable typehint or the is_callable() method will suffice here)
  • PlgSystemDebug::removeDisplayCallback() which takes one parameter:
    • $name is the name of the callable function to be removed.

Callable's Functionality[edit]

  • The callback function receives no parameters from the debug plugin and is expected to return a string (this should be HTML); this string is what is rendered in the debug console.

Language Key[edit]

How to translate the title:

  • The language key is a compound key, JText::_('PLG_DEBUG_' . strtoupper($name)), so the name you give your callable should be in a format allowed with the language parser
  • Add this key to your language files, for example with the above code snippet we should have a PLG_DEBUG_TEST="Testing New Feature" key somewhere.