Note: This is an article restored from archive. There zero reason not to use an IDE that has good PHP xdebug support at this point. The selection of PHP friendly IDEs at this time was poor.
Sometimes tracking down the source of a particularly frustrating bug can be tedious. Simply running
var_dump() here and there is problematic and not very elegant. Sometimes it’s nice to step through the code line by line and examine the values of variables at the point of execution.
There are several ways to accomplish the above, but on my setup (Mac + VirtualBox), I prefer MacGDBp.
To get it running, first you need to make sure Xdebug is installed. For me, I run Ubuntu in a VM, so
apt-get install php5-xdebug is enough to get me running. Next, you need to configure Xdebug to broadcast the debugging information and flow control over a port that MacGDBp can listen to:
[xdebug] xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_port=9000 xdebug.remote_autostart=1 xdebug.remote_connect_back=1
Note: Even though this is an old article restored from archive, this configuration still holds true for most modern setups.
Now your system has everything you need to listen to the dbgp protocol. After installing MacGDBp, running your php code will automatically stop progress and show up in the debug display. You can configure this to not stop on first launch and instead set breakpoints. Since Xdebug is an extension, you can insert
xdebug_break(); at any point in your code to stop execution and step through using this interface.
With just a small amount of effort, you can have an environment for properly debugging your code easily and effectively.
In many ways, PHP has come a long way to becoming a competent, typed language. With the newly minted PHP 8, strong types have eliminated a whole host …
Like many engineers, I have a life-long passion for learning. I satiate this need by creating side projects that explore new concepts, languages, and …
Do you remember back to your school days of writing a paper, giving it a once over, and turning it in only to be surprised on return of bad editing …
At Zumba, I implemented CSRF protection to all our state-changing user inputs. With a large and complicated site, implementing CSRF is a very tricky …