This document discusses debugging and profiling PHP applications using Xdebug. It provides instructions for installing Xdebug on different platforms and configuring it for debugging and profiling. It also describes how to trigger debug sessions from PHPStorm, Chrome extensions, and JavaScript bookmarklets. Alternative profiling tools like MCG and XHProf are mentioned as well.
7. Configure Xdebug for
Debugging
Turn on remote debugging:
xdebug.remote_enable=1
Configure what port, host, log file ... and more
xdebug.remote_port= 9000
xdebug.remote_log="/var/www/xdebug.log"
xdebug.remote_host="localhost"
9. Make sure you have the right PHP
Settings > PHP > Intrepreters
....you should see xdebug
10. Here is how to check symlinked or not
Tools > Deployment > Configuration
11. Gotchas
• Make sure profile directory exists and is writeable by
the web server
• Nothing works without xdebug.remote_enable=1
• Make sure port number matches in your ini and
phpstorm. Both default 9000
• SOOOOO many steps ... No shutup, stop being lazy
and just do it
12. How to trigger a debug session
• Javascript bookmarklets
• Chrome extension
• Within PhpStorm
• Magic
• Production crashes
Let's cover the first three
shall we?
13. Jetbrains Has The Goodies
http://www.jetbrains.com/phpstorm/marklets/
• Start Debugger:
• Goto page
• Hit Start Debugger
• Hit Stop Debugger when done debugging
• Debug this page:
• Goto page
• Hit Debug this page
22. XHProf
• Built by Facebook opensourced in 2009
• Xdebug not required
• Way more complicated to setup
• Documentation isn't great
• Requires you to add xhprof methods to your code
• Requires you to configure apache vhost for reporting
• Has callgraph charts (directed graphs) and a couple other nice features
Install isn't too bad with
homebrew or apt-get
23. In Review...
• Installed Xdebug
• Setup Xdebug with PhpStorm
• Configured Xdebug for profiling or debugging