2013年8月29日星期四

NetTuts.com: Xdebug - Professional PHP Debugging


On NetTuts.com there's a new article introducing Xdebug, a powerful tool that can help you with debugging your PHP applications. It works by investigating what's happening "on the inside" and reporting it back to your debugger.



Well, technically, Xdebug is an extension for PHP to make your life easier while debugging your code. [...] But just imagine for a moment, as your applications evolve, you might get into the habit of sprinkling your code all over with little echos, var_dumps and custom debuggers. [...] The next question is: how do you debug in production? [...] Now lastly, have you ever wished to be able to step through your code, line by line, watch expressions, and even step into a function call to see why it's producing the wrong return value? Well, you should definitely dig into the world of professional debugging with Xdebug, as it can solve all of the problems above.


They walk you through the setup of a complete (MAMP-based) environment on an OSX installation. You'll also need Xcode and the command line tools to be able to compile Xdebug. They recommend installing Homebrew to make installing the needed tools easier. They use Homebrew to install the PHP 5.4 version of Xdebug which then compiles and outputs a shared module you can put in your PHP extensions directory.



On the other side of things, the article also helps you set up your IDE, in this case PHPStorm but it would work for lots of others - to accept the debug messages from the server. He includes a sample script with some calls to the Xdebug-enabled debugging functions and what kind of responses (with screenshots) you should see in your IDE.


Link: http://net.tutsplus.com/tutorials/tools-and-tips/xdebug-professional-php-debugging/

没有评论:

发表评论