I watched the Creating a weblog in 15 minutes with Rails 2 and after 9 minutes in the video he shows ruby's interactive debugger, which allows you to call functions/methods from within a running script.
This goes way beyond breakpoints and looks very useful.
Is there something for PHP that gives similar functionality?
Install xdebug and then use one of the debug clients mentioned here.
Although Milen's answer is the only correct one circa 2009, and Xdebug is still a useful tool, using it requires you to recompile your PHP or to edit your php.ini
runtime configuration to load it as a shared object. It also means using a specific client application that supports its network protocol, such as an IDE like PhpStorm.
An alternative is phpdbg
, which is an interactive debugger that ships with PHP core versions 5.6 and later and can debug PHP scripts written to conform to PHP 5.4 or later.
Using it is simple:
phpdbg php_script_i_want_to_debug.php
Once in the debugger, type help
to access the help menu.
If you don't already have phpdbg
on your system, it may be because your PHP was configured without the --enable-phpdbg
option. You can either:
--enable-phpdbg
when you run ./configure
(this will simply also build the phpdbg
binary), orphpdbg
source independently and compile it against your installed PHP (assuming you have the PHP source available). Instructions for doing that, while sparse, are here.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With