DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

CCDebug

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:René Fritz
Changed:2003-12-19T20:03:56
Author:René Fritz
Email:r.fritz@colorcube.de
Info 3:
Info 4:

CCDebug

Extension Key: cc_debug

Copyright 2000-2002, René Fritz, <r.fritz@colorcube.de>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.com

Table of Contents

CCDebug 1

Introduction 1

Things to know 3

Configuration 3

Installation 3

Usage 4

To-Do list 4

Changelog 4

Introduction

The CCDebug extension provides extended functionality for PHP debugging inside of TYPO3.

The well known debug() function of TYPO3 prints all types of variables on top of a generated HTML page. This extension do similar but in a better way.

This works only on TYPO3 3.6 without patching the core. Read install instructions!

The main functionality is written by Dan Allen and is called errorReporter (see http://www.mojavelinux.com/cooker/demos/errorReporter/ ). The errorReporter code is adapted to TYPO3 into this extension. I made also some changes and small enhancements.

The main change to the functionality of errorReporter is the use of Luite van Zelst < luite@aegee.org > variable dump function which I like better than the original PHP code printer.

img-1 Ok, what in the end do CCDebug?In contrast to debug() which prints all output immediately, CCDebug collects all debug messages and opens a separate window for output. Also a small bomb in the upper right corner of the original page indicates errors. A click on the bomb icon opens the debug window. The bomb is a layer and will not destroy your page layout.

Let's have a look what Dan Allen wrote about errorReporter:

The error reporter is meant to sit on top of your application. PHP throws errors and you usually just see the PHP warning messages at the top of the page, catch the line and reload. But when you are doing more intricate applications, this is often not a convenient way to debug. Usually errors are thrown inside of functions which take large arrays and the error might be a little undefined index error.

When this script is initialized, it begins trapping all the non-fatal errors which occur on the page. When the page is finished loading, the Reporter object iterates over all of the captured errors and performs the specified reports based on the error level. This example demonstrates the 'console' report, which is a secondary window which can be opened to view the errors, source code and context at the time the error was thrown. (optional reports include email, file, system, browser and stdout, each to be used in the appropriate environment).

Each error report can take a minimum level onto which to act. This can be nice for a "live" system to send e-mail reports when a critical error occurs.”

In the CCDebug extension I deactivated the error handler which means that error messages from PHP are not piped into the debug window. I found it not very useful because PHP stops normally with a fatal error which will not be piped into the debug window for some reason and all the notices like 'Undefined index: ...' are boring :-)Anyway you can reactivate this feature by yourself.

The code also provide to output into a file, mail, ..., but haven't tried that yet.

Things to know

  • You can specify to exclude dumping of objects
  • You can exclude certain class objects
  • You can specify number of source code lines
  • You can specify strict context for variables
  • Click on bomb if error occurs in page (hidden if no errors)

Configuration

Installation

((generated))
TYPO3 V 3.6

You don't have to do anything special. Just install the extension and it should work.

TYPO3 V 3.5

You have to patch TYPO3. I hope the description below is still valid.

CCDebug provide a function debug() as a replacement for TYPO3's debug() function. Because it's not possible to redeclare the function you have to patch the file t3lib/config_default.php.

Search for function debug and name it function xdebug. Then paste this code in:

function debug($variable, $name='*variable*', $line='*line*', $file='*file*', $recursiveDepth=3, $debugLevel=E_DEBUG)      {
                // If you wish to use the debug()-function, and it does not output something,
                // please edit the IP mask in TYPO3_CONF_VARS
        if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv("REMOTE_ADDR"),
                      $GLOBALS["TYPO3_CONF_VARS"]["SYS"]["devIPmask"]))  return;

        if(@is_callable(array($GLOBALS['error'],'debug'))) {
                $GLOBALS['error']->debug($variable, $name, $line, $file, $level);
        } else {
                $name = ($name == '*variable*') ? 0 : $name;
                t3lib_div::debug($variable, $name);
        }
}

If you use the frontend gzip option you have to patch tslib/index_ts.php also:

// *************
// Debugging
// *************

if(@is_callable(array($error,'debugOutput'))) {
        $error->debugOutput();
}

// *************
// Compressions
// *************
if ($TYPO3_CONF_VARS['FE']['compressionLevel'])   {

Usage

With CCDebug put you have some additional parameters to the debug() function:

function debug($variable, $name = '*variable*', $line = '*line*', $file = '*file*', $level = E_DEBUG)

As you see you can pass

  • a name or description
  • the line number; this is normally done with the special PHP constant __LINE__
  • the script file name; normally passed with __FILE__
  • debug level; the PHP's predefined and some additional debug levels can be used

Unfortunately it's not possible to get the line number and file name automatically so you have to provide it in every debug() call with the PHP constants __LINE__ and __FILE__. You may create a macro in your editor.

These calls works all but gives less information in the debug window:

debug(time(), 'current time', __LINE__, __FILE__);
debug(time(), 'current time', __LINE__);
debug(time(), 'current time');
debug(time());

TODO

Configuration options

To-Do list

  • Full documentation.
  • maybe we can make the second parameter of:$reporter->addReporter('console', E_ERROR_ALL | E_WARNING_ALL | E_DEBUG);an option through localconf.php?
  • Implement debugBegin() and debugEnd() functions.
  • Add a debugMsg() function for “string messages” which might have a different rendering.

Changelog

It seems that PHP has a buggy error handler. Therefore PHP error handling by this extension is deactivated for now because of strange effects. Only errors from debug() function will be shown.

img-2 CCDebug - 4