I got PHPDBG enabled in PHP 5.4 although I’ve never bothered giving it a try. Recently, I decided to play around with it to try to compare it with Xdebug. I tested it with a minimal Drupal installation.
PHP and PHPDBG
I use homebrew-php to install PHP 5.4. Versions 5.4+ have the flag --with-phpdbg if you wish to include PHPDBG during installation therefore installation is simply via invoking brew install php54 --with-phpdbg.
The version of PHPDBG that comes with the php54 package is v0.3.2. I gave this a try but didn’t much like it as it had a lot of bugs. What worked for me was replacing it with the one that had the latest changes (specifically this). It still had a few bugs in it but it was way better. I had to change the source of homebrew-php to make it work. Here’s a diff of my changes at homebrew-php installation directory:
I had a minimal installation of Drupal. I simply grabbed Drupal 7 and installed it via drush si --db-url=sqlite://sites/default/files/.ht.sqlite -y.
The documentation is a bit difficult to understand considering that I am relatively new to debugging. Unlike Xdebug, you’ll need to mock a webserver to get PHPDBG to work with web applications like Drupal. An example can be found from both the repository and documentation. I used it like this:
The file needs to be modified for it to work with Drupal. I made the following changes to it:
Set a breakpoint by invoking break func_name and finally invoking run to start debugging. step would step through each line of code. ev can be used to evaluate expressions. An example is inspecting the available variables in the current scope and stack frame.
I did it like this:
I haven’t figured out some of the other basic usages such as stepping over a line rather than stepping through it.