Archive for category php
Basic PHP Debugging with FirePHP (Firebug style)
FirePHP is a Firebug extension that let’s you debug PHP in the same manner as you would Javascript using Firebug.
In a nutshell you include the core FirePHP library, call `ob_start()`, call the FirePHP method `fb()` and pass it some stuff to output. Check the Firebug console for your output. It’s that simple.
One problem I ran into… I KNEW I had everything set up correctly (installed, correct paths, code in the right places) but it still didn’t output anything to the console. Usually when this happens it is just me making a stupid syntax error or using the wrong path but I triple checked and it wasn’t me (for once). The solution? Restart Firefox. Why? No idea… I had FirePHP installed and working for a year or so prior to this so it wasn’t some fresh install that hadn’t registered or some such… just wasn’t working. So if nothing is working and you are certain your path is correct (and paths are usually the problem, by the way) as a last resort, restart Firefox.
Installation:
1. Get the plugin
2. Get the core FirePHP library using Pear:
pear channel-discover pear.firephp.org
pear install firephp/FirePHPCore
with my MAMP install the path to pear is different so I use:
/Applications/MAMP/bin/php5/bin/pear channel-discover pear.firephp.org
/Applications/MAMP/bin/php5/bin/pear install firephp/FirePHPCore
*Note: If you are on a Mac you probably already have a copy of pear in your path so you may have to specify the exact copy of pear you want to use, like I do with the MAMP install.
Usage
- At the top of the PHP page you are debugging:
//FireBug require_once('FirePHPCore/fb.php'); ob_start(); // End Firebug - At the bottom of the page:
// Any Firebug output code goes here fb($pageOffset, "pageOffset"); fb($intNumberOfPages, "intNumberOfPages: "); fb($minValue, "minvalue: "); fb($maxValue, "maxvalue: "); // End Firebug Output code
The Output:






