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.

EXT: Debugger

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:Franz Holzinger
Changed:2015-01-02T21:44:06.248894058
Classification:fh_debug
Keywords:forDevelopers, forBeginners
Author:Franz Holzinger
Email:franz@ttproducts.de
Info 4:
Language:en

img-1 img-2 EXT: Debugger - fh_debug

EXT: Debugger

Extension Key: fh_debug

Language: en

Keywords: forDevelopers, forBeginners

Copyright 2010-2015, Franz Holzinger, <franz@ttproducts.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.org

Table of Contents

EXT: Debugger 1

`Introduction 3 <#__RefHeading__827_1211893060>`_

What does it do? 3

Screenshots 4

`Users manual 5 <#__RefHeading__967_1211893060>`_

debug file 5

devLog 5

`Known problems 6 <#__RefHeading__833_1211893060>`_

`ChangeLog 7 <#__RefHeading__835_1211893060>`_

Introduction

What does it do?

  • This is a simple PHP debugger.Put this into your PHP file:

    debugBegin();
    debug ($variable, '$variable');
    debugEnd();
    

    You can add the IP address for debug output in the EM. Enter the filename to put all output into a HTML file instead of the screen.

  • You can see all the debug output if you use the debug file. Make sure you have the DEBUGFILEMODE set to 'o' for overwriting. Otherwise nothing will be written, if the file already has contents! And verify the starting date and time to see that the debug really has been written during your last PHP session.

  • Read the EM for fh_debug. All documentation is directly written there.

  • Support for the logging of errors into your own file instead of the PHP error_log file. Just insert lines like these into your PHP file for the TYPO3 Core or for a TYPO3 extension:

    $backtrace = \JambageCom\Fhdebug\Utility\DebugFunctions::getTraceArray();
    error_log('my debug code position 1 - backtrace: ' . print_r($backtrace, TRUE) . chr(13), 3, \JambageCom\Fhdebug\Utility\DebugFunctions::getErrorLogFilename());
    
  • If you debug the TYPO3 Core on a place where the autoloader did not already include the files of fh_debug or in the file ext_localconf.php of a TYPO3 extension, you can use this approach example:

    public function create($cacheIdentifier, $cacheObjectName, $backendObjectName, array $backendOptions = array()) {
     class CacheFactory implements \TYPO3\CMS\Core\SingletonInterface {
    
    // now add the following lines to generated the debug output
    if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('fh_debug')) {
         require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fh_debug') . 'Classes/Utility/DebugFunctions.php');  // use t3lib_extMgm::extPath in TYPO3 4.5
            // some configuration:
            \JambageCom\Fhdebug\Utility\DebugFunctions::setErrorLogFile(''); // this is necessary if you use the error_log file
            // if you use the debug HTML file:
            \JambageCom\Fhdebug\Utility\DebugFunctions::setDebugFile('fileadmin/debug.html');
    
      \JambageCom\Fhdebug\Utility\DebugFunctions::setDebugBegin(FALSE);
      \JambageCom\Fhdebug\Utility\DebugFunctions::setRecursiveDepth('12');
      \JambageCom\Fhdebug\Utility\DebugFunctions::setTraceDepth('12');
      \JambageCom\Fhdebug\Utility\DebugFunctions::setAppendDepth('0');
      \JambageCom\Fhdebug\Utility\DebugFunctions::setTypo3Mode('ALL');
      \JambageCom\Fhdebug\Utility\DebugFunctions::setActive(TRUE);
      \JambageCom\Fhdebug\Utility\DebugFunctions::initFile();
    
            // show the values of some variables:
            \JambageCom\Fhdebug\Utility\DebugFunctions::debug($cacheIdentifier, 'create $cacheIdentifier');
            \JambageCom\Fhdebug\Utility\DebugFunctions::debug($cacheObjectName, 'create $cacheObjectName');
            \JambageCom\Fhdebug\Utility\DebugFunctions::debug($backendObjectName, 'create $backendObjectName');
            \JambageCom\Fhdebug\Utility\DebugFunctions::debug($backendOptions, 'create $backendOptions');
            \JambageCom\Fhdebug\Utility\DebugFunctions::close();
    }
    

Screenshots

Here you see what the extension does:

img-3

The debug info is stored as a HTML file. The variable name, contents and type are shown together with leading backtrace lines.

Users manual

debug file

Use the generated debug file, which by default is http://exampletypo3.com/fileadmin/debug.html .You must add the '</body>' HTML tag to the end of the file. This is because the debugger does not know how many output you will add there if you use the append functionality.

In order to make sure that the debugging will be activated from the beginning of the TYPO3 process, you must follow this step. Add this line into your file typo3conf/AdditionalConfiguration.php. Maybe you need to create this file.

<?php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'][] = 'JambageCom\\FhDebug\\Hooks\\CoreHooks->preprocessRequest';
?>

errorLog

The default error_log file of the extension fh_debug is “fileadmin/phpDebugErrorLog.txt”.You can use the error_log in a case when there are troubles using the debug output file.

devLog

You can add calls to the devLog logging function to your PHP files.

This will be transformed into debug entries in the debug file.

Example:
$dataVar = array('important' => 'We need more cardboard', 'data' => 'size 1m x 0.5 m');
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog($myDebug, 'myextensionkey', 0, $dataVar);

This will be transformed into debug entries of a variable named “$devLogArray” in the debug file.

Known problems

If you want to debug the file ext_localconf.php, then make sure that fh_debug is installed before that extension. Otherwise the global error object is not initialized and nothing will be debugged.

No debug output is shown with backend debugging:Increase the numer 'Append [APPENDDEPTH]'. Sometimes the cached localconf.php is called several times. Then the debug output could have been overwritten by another PHP session. If you set this number high enough and repeat the execution of the PHP code, then in the end you will see its output.

No debug output is shown from the file ext_localconf.php of my extension.Make sure that the extension fh_debug has been installed before your extension. You can change the order in the variable $TYPO3_CONF_VARS['EXT']['extList'] of the file typo3conf/localconf.php .

The EM of TYPO3 4.5 and later overwrites the global error object.If you want to use fh_debug in TYPO3 4.5-4.7 for the debugging of the backend, then you must modify the file t3lib/extjs/class.t3lib_extjs_extdirectrouter.php on line 45 and comment out that line.

// $GLOBALS['error'] = t3lib_div::makeInstance('t3lib_extjs_ExtDirectDebug');

In TYPO3 6.0 you must modify the file typo3/sysext/core/Classes/ExtDirect/ExtDirectRouter.php and comment out that line.

public function route($ajaxParams, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
//              $GLOBALS['error'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\ExtDirect\\ExtDirectDebug');

If no debug output is shown, then you should check your settings for STARTFILES (remove each start file) and APPENDDEPTH (set it to higher values).

Check your PHP error_log file and give the write access rights to the debug file:

[Mon Jun 03 13:24:30 2013] [error] [client 85.197.0.222] PHP Warning: error_log(/var/www/mydomain/fileadmin/phpDebugErrorLog.txt): failed to open stream: Permission denied in /var/www/mydomain/trunk/typo3/ext/fh_debug/lib/class.tx_fhdebug.php on line 859, referer: http://www.mydomain.com/typo3/backend.php

If you want to debug the file ext_localconf.php or ext_tables.php, then make sure that fh_debug has been installed before the extension which you want to debug.

Some browser fail to load large HTML files with a size of about 100 MByte.Use the split command to divide the debug.html into many fileswith sizes of 10 MByte:

split -b 10m fileadmin/debug.html
mv fileadmin/xak  fileadmin/xak.htm

ChangeLog

initial upload

7