Debug PHP applications with Xdebug and Komodo
Takeaway: Learn to configure Xdebug and Komodo to work together and provide debugging for PHP applications on your server.
Good developers use good tools and design when writing applications, and the same is true for Web-based applications written in PHP. Two tools that are very valuable for PHP applications are Komodo and Xdebug. Komodo is a cross-platform IDE that can handle debugging remote PHP applications using the DBGp protocol, and Xdebug is an extension for PHP that provides debugging support. Put them together and you are able to remotely debug any PHP applications on your server.
The first step is to install Xdebug on the server where the scripts to be debugged are being run. This can be easily accomplished using PECL. You will need to install the Apache, PHP, and PEAR development files; most Linux distributions provide these as packages, such as apache-devel, php-devel, and perhaps php-pear. With these packages or your distribution's equivalent, execute:
# pecl install xdebug-beta
Some distributions provide packaged Xdebug binaries, so look for that first; if it's not included, you'll need the Apache/PHP development files to build it from source. Once that's done, edit /etc/php.ini or the equivalent and add:
zend_extension=/usr/lib/php/extensions/xdebug.so
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
;xdebug.idekey=
Unless you are planning on running the IDE on the same host, change the Xdebug.remote_host keyword from localhost to the hostname of the machine you will be running the IDE on.
With Komodo, make sure that you configure debugging support correctly. Enter Preferences -> Debugger -> Connection and set the port to the port you defined above with xdebug.remote_port (in this case, 9000). Make sure that Debug -> "Listen for remote debugger" is checked.
Configuration is done. If you haven't done so already, restart Apache on the server and then browse to a page on your site. Load the page, but append the XDEBUG_SESSION_START get variable to the URL, for instance:
http://devel.mysite.com/blog/submit.php?XDEBUG_SESSION_START=1
If everything is configured correctly, Komodo should alert you that a remote application has requested the debugging session to start. Select Yes, and you will have a new document open with the code of the page and the debugging session beginning.
If it doesn't work the first time, make sure that the remote server has straight access to the debugger's port on the machine. If there is a firewall in between the IDE and the server, you'll need to make sure the firewall forwards connections on that port to the computer that the IDE is running on.
Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!
Print/View all Posts Comments on this article
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- Unrivaled support from Novell, now available for Red Hat Novell If Linux is going to power your mission-critical applications, you'd ... Download Now
- Achieving Cost and Resource Savings with UC white paper Microsoft In this harsh economic climate, the need is more compelling than ever to ... Download Now
- Live Webcast: Oracle Business Intelligence for Midsize Companies: More Than Just Pretty Dashboards Oracle Oracle's Business Intelligence solutions are widely recognized as market ... Download Now
- Business Value of Windows Server 2008 R2 Hyper-V and Live Migration Microsoft Today's IT departments are under increasing pressure to manage and support ... Download Now
- Microsoft Hosted Volume Activation (Using MAK) Microsoft Microsoft? Volume Activation helps Volume Licensing customers automate and ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
