Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Efficiently Debugging TYPO3

From TYPO3Wiki
Jump to: navigation, search

This page describes how efficiently debugging TYPO3. If you need a PHP editor / IDE, please refer to Comparison of PHP Editors for TYPO3 development.

Draft Change the {{draft}} marker to {{review}} when you need a reviewer for text and TypoScript. info

Contents

PDT and Zend Server Community Edition

Installing and Configuring

How-to debug

XDebug

Installing and Configuring

Assumption: You run XAMPP with PHP 5.2.2 in C:\xampp

64 bit Notice: XDebug has problems on 64bit systems. Version working well on 64bit Win7 with php 5.2.2 is [XDebug 2.0.0].

For this setup, download the linked .dll file and place it in C:\xampp\php\ext

Open your php.ini file in C:\xampp\php\php.ini (Make sure this is the actually used file, older versions of XAMPP used c:\xampp\apache\bin\php.ini) At the very bottom of that file, comment everything in the Zend section so it is not used anymore. Enter this information in the XDebug section

[XDebug]
zend_extension_ts="C:\xampp\php\ext\php_xdebug-2.0.0-5.2.2.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.show_local_vars = 1

and in case you want to use wincachegrind for profiling (warning this is slow and generates huge amounts of data):

xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"

(Personally I prefer XHProf for profiling but it does not come in a windows version right now.)

Restart your Apache server, visit a page with phpinfo() and check if there is a section on XDebug. If there isn't check your filenames and locations and if you edit the correct php.ini file.

Configure Eclipse Galileo PDT for Xdebug

  • Click Run -> Debug Configurations
  • Select "PHP Web Page" and click the icon for "New launch configuration"
  • In the "Server" tab, select Server Debugger "XDebug"
  • for the file, browse to your Typo3 index.php
  • Leave URL on auto generate and choose break at first line as you like it.
  • Click debug and you are running a debugger.

Regarding the correct paths: Assuming you have your Eclipse Workspace in c:\web and a typo3 project named www in C:\web\www with your Apache document root in your workspace directory c:\web. (This means you can get to your Typo3 website on http://localhost/www)... You will have to choose the following as debug configuration:

  • File: /www/index.php
  • Leave URL to auto generate which will use http://localhost/ in the left part and /www/index.php in the right one.

Some notes:

  • You can choose a different default browser (e.g. Firefox) by pressing "Window -> Web Browser"
  • You can set Breakpoints by double-clicking in the left border of the editor window (where TODO or FIXME marks are shown)
  • Sometimes, the debug session does not stop any more, then you simply have to end the web launch and start it again.
  • When debugging Cron Scripts, you can select the debug configuration "PHP Script" using the executable at c:\xampp\php\php.exe

Configure NetBeans 6.8 for debugging

  • Install xdebug as explained before.
  • In the project listing of NetBeans, right-click on the project which you want to debug, and open "Properties". This opens the Project Properties dialog.
  • Then, modify the "Run Configuration" as follows:
    • Run as: Local web site
    • Project URL: [Base URL to your TYPO3 instance], like http://localhost/typo3v4/
    • Index File: (leave blank)
    • Arguments: (leave blank)
  • Now click on "Advanced", and set the "Debug URL" to "Ask Every Time".
  • That's basically it :-)

To use debugging, do the following:

  • Set a breakpoint inside the project you just set up, and click debug in the main toolbar.
  • Now, a popup opens where you can enter the URL of the website which should be called. Enter the URL which triggers the desired functionality.
  • Your browser opens and starts loading. Now, go back to NetBeans, and see that it is waiting on a break point for your attention :-)
  • Happy debugging!

How-to debug

Further Reading

debug

Go to: typo3.org    
Login, and you can edit.
Personal tools
Namespaces

Variants
Actions