debugging php with xdebug inside of eclipse pdt 2.1

34
Debugging PHP with Xdebug Inside of Eclipse PDT 2.0 Bastian Feder papaya Software GmbH IPC 2009 18.11.2009

Upload: bastian-feder

Post on 06-May-2015

10.798 views

Category:

Technology


2 download

DESCRIPTION

Integrated development plattforms (IDEs) like Eclipse or Netbeans do get more popular these days. One cause might be the beautiful benefits a developer gains from using an IDE like a type history or a code completion. This talk shall enable the attendee to get knowleadge about the possibilites of Eclipse PDT to use xDebug as internal debugger It shows howto install xDebug and give a deep introduction about how to enable Eclipse PDT version 2 to communicate with xDebug. Another topic of this talk would be the different debugging mechanism Eclipse PDT provides and how they work.

TRANSCRIPT

Page 1: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging PHPwith

XdebugInside of

Eclipse PDT 2.0

Bastian Federpapaya Software GmbH

IPC 200918.11.2009

Page 2: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Me, myself & I

Application developer PHP since 2001 @papaya since

01.2008 OpenSource addict

▹ fluentDom.org

▹ CaricaCacheGrind

Page 3: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Who are you?

Page 4: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Derrick Rethans

„ Xdebug ̶

PHP developer's Swiss-Army Knife “

Page 5: Debugging PHP with xDebug inside of Eclipse PDT 2.1

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

Page 6: Debugging PHP with xDebug inside of Eclipse PDT 2.1

What's up for this talk?

Installation Configuration Techniques Eclipse PDT Troubleshooting

Page 7: Debugging PHP with xDebug inside of Eclipse PDT 2.1

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 GroupZend 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

Page 8: Debugging PHP with xDebug inside of Eclipse PDT 2.1

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

Page 9: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Obtaining Xdebug – precompiled Modules

ActiveState

▹ Komodo IDE Xdebug binaries (http://downloads.activestate.com/Komodo/releases/5.2.2/remotedebugging)

Page 10: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Configuration

Add to php.ini

[XDebug] ;; Only Zend OR (!) XDebug zend_extension="/usr/local/php/modules/xdebug.so"

[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

Page 11: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Configuration (II)

.htaccess – file settings

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

php_value xdebug.remote_enable 1 php_value xdebug.remote_handler bdgp php_value xdebug.remote_host 127.0.0.1 ;if debugging on remote server, put client IP here

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"

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

php_value xdebug.remote_enable 1 php_value xdebug.remote_handler 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"

Page 12: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging techniques

Local debugging

Page 13: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging techniques (II)

Remote debugging

Page 14: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging techniques (III)

Multi-User Debugging

▹ Only possible using Remote Debugging

▹ DBGp Proxy necessary

Page 15: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Eclipse PDT

Page 16: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Eclipse PDT

Debug Perspective Debug Views Support for

▹ Breakpoints

▹ Conditional Breakpoints

▹ Live view / edit of variable content

▹ All debugging techniques

Page 17: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging perspective

Page 18: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Preferences – Basic setup

Page 19: Debugging PHP with xDebug inside of Eclipse PDT 2.1

General settings

Debug Port Multisession DBGp Proxy settings

Page 20: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Preferences – Basic setup

Page 21: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Preferences – PHP servers

Remote debugging Mapping between IDE and Xdebug

Page 22: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Configuration for remote debugging

Page 23: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Start a remote debugging session

Page 24: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Start a local debugging

Page 25: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Configure „autostart“ options

Accept JIT

▹ Localhost

▹ any

▹ Prompt Disable Multisession

currently a Bug in PDT

Page 26: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debug CLI scripts

Preconditions

▹ JIT configured

▹ Breakpoint set or 'Break at first line' active Debug cronjobs, PHPUnit tests, etc.

#> export XDEBUG_CONFIG=“idekey=ECLIPSE_DBGP“↵

#> php myScript.php ↵

#> export XDEBUG_CONFIG=““ ↵

Page 27: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Debugging made easy!

Firefox Add-on „Xdebug Helper“

Page 28: Debugging PHP with xDebug inside of Eclipse PDT 2.1

DEMO

Page 29: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Troubleshooting

Monitor TCP/IP

▹ Withershark / ethereal

▹ TCP/IP Monitor

Page 30: Debugging PHP with xDebug inside of Eclipse PDT 2.1

TCP/IP Monitor (remote debugging only)

Page 31: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Questions?

Further questions? Ask me at:

[email protected]

Page 32: Debugging PHP with xDebug inside of Eclipse PDT 2.1

Contact'n Slides

Slides▹ SlideShare: http://slideshare.com/lapistano

Contact▹ Blog: http://bastian-feder.de

▹ Email: [email protected]

Rate the talk @ http://joind.in/talk/view/1066

Page 33: Debugging PHP with xDebug inside of Eclipse PDT 2.1

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 )

Page 34: Debugging PHP with xDebug inside of Eclipse PDT 2.1

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