KEMBAR78
Debugging PHP with xDebug inside of Eclipse PDT 2.1 | PDF
Debugging PHP
                             with
                            Xdebug
                           Inside of
                       Eclipse PDT 2.0


Bastian Feder                             IPC 2009
papaya Software GmbH                     18.11.2009
Me, myself & I
           Application developer
           PHP since 2001
           @papaya since
            01.2008
           OpenSource addict
               ▹   fluentDom.org
               ▹   CaricaCacheGrind
Who are you?
Derrick Rethans



„ Xdebug   ̶

 PHP developer's Swiss-Army Knife   “
What is this xDebug ev'ryone's talking about?
   Debugging for PHP by Derick Rethans
    (http://www.xdebug.org)
   Provides
        ▹   profiling, tracing, code coverage, …
        ▹   PHP error reporting enhancements
   Cross platform
What's up for this talk?
   Installation
   Configuration
   Techniques
   Eclipse PDT
   Troubleshooting
Obtaining Xdebug - Linux

       #> sudo apt-get install php5-xdebug ↵

       #> php -v ↵

      PHP 5.2.-3ubuntu4.2 with Suhoshin-Patch 0.9.6.2 (cli)
      Copyright © 1997-2008 The PHP Group
      Zend Engine v2.2.0, Copyright © 2002-2008 Zend Technologies
        with Xdebug v2.0.5, Copyright © 2002-2008, by Derick Rethans


   Easiest way on Linux systems
   Basic configuration
Obtaining Xdebug - PECL

       #> sudo pecl install xdebug ↵


   Still configurations to be done
       ▹   Add:
             zend_extension=“/usr/local/php/modules/xdebug.so

         to php.ini
   Ignore notes about to add
    „extension=xdebug.so“ → causes problems
Obtaining Xdebug – precompiled Modules




   ActiveState
       ▹   Komodo IDE Xdebug binaries
            (http://downloads.activestate.com/Komodo/releases/5.2.2/remotedebugging)
Configuration
   Add to php.ini

[XDebug]
;; Only Zend OR (!) XDebug
zend_extension="/usr/local/php/modules/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1 ;if debugging on remote server, put client IP here
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

;; profiler
xdebug.profiler_enable=Off
xdebug.profiler_enable_trigger=On
xdebug.profiler_output_dir=/data_lokal/temp/xdebug/profiling
Configuration (II)
     .htaccess – file settings

#-------------------------------#
# xDebug section            #
#-------------------------------#

php_value xdebug.remote_enable 1
php_value xdebug.remote_handler bdgp
                                dbgp
php_value xdebug.remote_host 127.0.0.1 ;if debugging on remote server, put client IP here
php_value xdebug.allowed_clients <client IP address>
php_value xdebug.remote_port 9000

# profiler
php_value xdebug.profiler_enable_trigger 1
php_value xdebug.profiler_enable 0
php_value xdebug.profiler_output_dir "/data_lokal/temp/xdebug/profiling"
Debugging techniques
   Local debugging
Debugging techniques (II)
   Remote debugging
Debugging techniques (III)
   Multi-User Debugging
       ▹   Only possible using Remote Debugging
       ▹   DBGp Proxy necessary
Eclipse PDT
Eclipse PDT
   Debug Perspective
   Debug Views
   Support for
       ▹   Breakpoints
       ▹   Conditional Breakpoints
       ▹   Live view / edit of variable content
       ▹   All debugging techniques
Debugging perspective
Preferences – Basic setup
General settings
   Debug Port
   Multisession
   DBGp Proxy settings
Preferences – Basic setup
Preferences – PHP servers
   Remote debugging
   Mapping between IDE and Xdebug
Configuration for remote debugging
Start a remote debugging session
Start a local debugging
Configure „autostart“ options
   Accept JIT
       ▹  Localhost
        ▹ any
        ▹ Prompt
   Disable Multisession
    currently a Bug in PDT
Debug CLI scripts

       #> export XDEBUG_CONFIG=“idekey=ECLIPSE_DBGP“↵

       #> php myScript.php ↵

       #> export XDEBUG_CONFIG=““ ↵




   Preconditions
        ▹JIT configured
       ▹ Breakpoint set or 'Break at first line' active
   Debug cronjobs, PHPUnit tests, etc.
Debugging made easy!
   Firefox Add-on
    „Xdebug Helper“
DEMO
Troubleshooting
   Monitor TCP/IP
       ▹   Withershark / ethereal
       ▹   TCP/IP Monitor
TCP/IP Monitor (remote debugging only)
Questions?




             Further questions? Ask me at:

             lapistano@php.net
Contact'n Slides
   Slides
       ▹   SlideShare: http://slideshare.com/lapistano
   Contact
       ▹   Blog: http://bastian-feder.de
       ▹   Email: php@bastian-feder.de
   Rate the talk @ http://joind.in/talk/view/1066
References
   xDebug
    (http://www.xdebug.org)

           ▹   Komodo precompilations
                  (http://downloads.activestate.com/Komodo/releases/5.2.2/remotedebugging)

           ▹   DBGp Proxy
                  (http://derickrethans.nl/debugging_with_multiple_users.php)

   Eclipse PDT
    (http://www.eclipse.org/pdt)

   Xdebug-Helper
    (https://addons.mozilla.org/en-US/firefox/addon/3960 )
License
   This set of slides and the source code included
    in the download package is licensed under the

        Creative Commons Attribution-
     Noncommercial-Share Alike 2.0 Generic
                   License


      http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en

Debugging PHP with xDebug inside of Eclipse PDT 2.1

  • 1.
    Debugging PHP with Xdebug Inside of Eclipse PDT 2.0 Bastian Feder IPC 2009 papaya Software GmbH 18.11.2009
  • 2.
    Me, myself &I  Application developer  PHP since 2001  @papaya since 01.2008  OpenSource addict ▹ fluentDom.org ▹ CaricaCacheGrind
  • 3.
  • 4.
    Derrick Rethans „ Xdebug ̶ PHP developer's Swiss-Army Knife “
  • 5.
    What is thisxDebug ev'ryone's talking about?  Debugging for PHP by Derick Rethans (http://www.xdebug.org)  Provides ▹ profiling, tracing, code coverage, … ▹ PHP error reporting enhancements  Cross platform
  • 6.
    What's up forthis talk?  Installation  Configuration  Techniques  Eclipse PDT  Troubleshooting
  • 7.
    Obtaining Xdebug -Linux #> sudo apt-get install php5-xdebug ↵ #> php -v ↵ PHP 5.2.-3ubuntu4.2 with Suhoshin-Patch 0.9.6.2 (cli) Copyright © 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright © 2002-2008 Zend Technologies with Xdebug v2.0.5, Copyright © 2002-2008, by Derick Rethans  Easiest way on Linux systems  Basic configuration
  • 8.
    Obtaining Xdebug -PECL #> sudo pecl install xdebug ↵  Still configurations to be done ▹ Add: zend_extension=“/usr/local/php/modules/xdebug.so to php.ini  Ignore notes about to add „extension=xdebug.so“ → causes problems
  • 9.
    Obtaining Xdebug –precompiled Modules  ActiveState ▹ Komodo IDE Xdebug binaries (http://downloads.activestate.com/Komodo/releases/5.2.2/remotedebugging)
  • 10.
    Configuration  Add to php.ini [XDebug] ;; Only Zend OR (!) XDebug zend_extension="/usr/local/php/modules/xdebug.so" xdebug.remote_enable=true xdebug.remote_host=127.0.0.1 ;if debugging on remote server, put client IP here xdebug.remote_port=9000 xdebug.remote_handler=dbgp ;; profiler xdebug.profiler_enable=Off xdebug.profiler_enable_trigger=On xdebug.profiler_output_dir=/data_lokal/temp/xdebug/profiling
  • 11.
    Configuration (II)  .htaccess – file settings #-------------------------------# # xDebug section # #-------------------------------# php_value xdebug.remote_enable 1 php_value xdebug.remote_handler bdgp dbgp php_value xdebug.remote_host 127.0.0.1 ;if debugging on remote server, put client IP here php_value xdebug.allowed_clients <client IP address> php_value xdebug.remote_port 9000 # profiler php_value xdebug.profiler_enable_trigger 1 php_value xdebug.profiler_enable 0 php_value xdebug.profiler_output_dir "/data_lokal/temp/xdebug/profiling"
  • 12.
  • 13.
  • 14.
    Debugging techniques (III)  Multi-User Debugging ▹ Only possible using Remote Debugging ▹ DBGp Proxy necessary
  • 15.
  • 16.
    Eclipse PDT  Debug Perspective  Debug Views  Support for ▹ Breakpoints ▹ Conditional Breakpoints ▹ Live view / edit of variable content ▹ All debugging techniques
  • 17.
  • 18.
  • 19.
    General settings  Debug Port  Multisession  DBGp Proxy settings
  • 20.
  • 21.
    Preferences – PHPservers  Remote debugging  Mapping between IDE and Xdebug
  • 22.
  • 23.
    Start a remotedebugging session
  • 24.
    Start a localdebugging
  • 25.
    Configure „autostart“ options  Accept JIT ▹ Localhost ▹ any ▹ Prompt  Disable Multisession currently a Bug in PDT
  • 26.
    Debug CLI scripts #> export XDEBUG_CONFIG=“idekey=ECLIPSE_DBGP“↵ #> php myScript.php ↵ #> export XDEBUG_CONFIG=““ ↵  Preconditions ▹JIT configured ▹ Breakpoint set or 'Break at first line' active  Debug cronjobs, PHPUnit tests, etc.
  • 27.
    Debugging made easy!  Firefox Add-on „Xdebug Helper“
  • 28.
  • 29.
    Troubleshooting  Monitor TCP/IP ▹ Withershark / ethereal ▹ TCP/IP Monitor
  • 30.
    TCP/IP Monitor (remotedebugging only)
  • 31.
    Questions? Further questions? Ask me at: lapistano@php.net
  • 32.
    Contact'n Slides  Slides ▹ SlideShare: http://slideshare.com/lapistano  Contact ▹ Blog: http://bastian-feder.de ▹ Email: php@bastian-feder.de  Rate the talk @ http://joind.in/talk/view/1066
  • 33.
    References  xDebug (http://www.xdebug.org) ▹ Komodo precompilations (http://downloads.activestate.com/Komodo/releases/5.2.2/remotedebugging) ▹ DBGp Proxy (http://derickrethans.nl/debugging_with_multiple_users.php)  Eclipse PDT (http://www.eclipse.org/pdt)  Xdebug-Helper (https://addons.mozilla.org/en-US/firefox/addon/3960 )
  • 34.
    License  This set of slides and the source code included in the download package is licensed under the Creative Commons Attribution- Noncommercial-Share Alike 2.0 Generic License http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en