Featured Post

[PL] Problem tysiąca i jednej kontrolki

Liczba tysiąc była przez wieki dla wielu osób liczbą magiczną. Łacina oznaczała ją literą M (łac. Millenium). W roku 2000 wszyscy mieliśmy okazję doświadczyć tzw. pluskwy milenijnej lub problemu roku 2000, związanego z datowaniem. Otóż do roku 2000 w wielu systemach posługiwano...

Read More

Integrating FirePHP with Zend Framework 2

Posted by Tomasz Kuter | Posted in Programming, Web development | Posted on 22-03-2013

Tags: , , , , , , , , , , , , ,


In this post I will show you how to easily integrate FirePHP – Mozilla Firefox extension with Zend Framework 2. FirePHP enables you to log to your Firebug Console using a simple PHP method call. All data is sent via response headers and will not interfere with the content on your page. FirePHP is ideally suited for AJAX development where clean JSON and XML responses are required.

General information

At the beginning some basic notes:

So download server side version and unpack the archive.
Find the FirePHPCore inside and copy it to /vendor/firephp directory.

At this step you should have FirePHP.class.php in the /vendor/firephp/FirePHPCore/.

Now rename FirePHP.class.php to FirePHP.php.

Once you successfully installed FirePHP extension in Mozilla Firefox you can get to next step – setting up the Zend\Log in our tutorial application.

Setup Zend\Log

File /config/autoload/global.php should look like:

As you could notice – we have two writers:

  • FirePhp,
  • and Stream.

Stream writer needs appropriate directory permissions to be able to write in the /data/log directory.

And this should be all. You can check the Firebug console if you successfully see the message from the FirePHP:

Logging debug messages

To use FirePHP in your code you need to get Zend\Log instance and execute one of following methods on the Log object:

  • $log->info(‘info message’);
  • $log->crit(‘critical error message’);
  • $log->err(‘error message’);
  • $log->warn(‘warning message’);
  • $log->notice(‘notice message’);
  • $log->debug(‘debug message’);

So let’s check it in Album controller:

FirePHP enabled

FirePHP enabled

Advanced usage of FirePHP

More FirePHP options: e.g. grouping, data labeling, etc you can find on the following page:

All the code you can download from the below link:


Integrating FirePHP library with Zend Framework 2 can be much more simple. All you need to do is to modify Composer configuration file. More info in another post of this blog.

Comments (1)

Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

Write a comment