cakephpfirebugfirephp

Debugging ajax calls on CakePHP 2 with DebugKit, Firebug et al


I have a CakePHP 2 app with DebugKit installed. It is working fine and I get the memory usage and processing time in the "Timing" toolbar for each page I load.

What I also want to be able to do is get memory usage and processing times for ajax requests after the page has loaded. I am aware that I can access previous ajax requests using the "History" button in the DebugKit Toolbar, but this is doesn't really help when I want to click around the page, firing ajax requests and get instant debugging information for them.

So, I did some searching and I found that I could use Firebug + FirePHP in Firefox along with the FirePHP and FireCake libraries in my app and get all of DebugKit's stats on a per-ajax-request basis. This sounds perfect and exactly what I want to do.

Unfortunately, I can't seem to get it to work. I could only find one tutorial on the matter at http://someguyjeremy.com/blog/using-firephp-to-debug-your-cakephp-app

I have done everything that tutorial mentions and Cake gives me no errors at all. However, unless I am missing something, I don't see where in Firebug the debug info is being displayed, if indeed it is even being fed to Firebug in the first place.

My config:

Cake Version: 2.2.4

Firefox Version: 17.0.1

Firebug Version: tried with 1.11.1 and 1.9.0

FirePHP Version: 0.7.1

DebugKit Version: 2.2.0 (latest master branch)

UPDATE

It appears to work perfectly for Ajax requests that do not end in .json and, therefore, are not being picked up by the Router::parseExtensions('json'); I have in routes.php.

I took out Router::parseExtensions('json'); and changed my Ajax request to go for my filter action directly instead of calling it filter.json and Cake serves all of the FireBug headers. Unfortunately, I can't use it like this because JQuery needs the content type to be application.json.


Solution

  • It looks like this might be a documented bug:

    http://cakephp.lighthouseapp.com/projects/42880/tickets/107-firephp-messages-are-not-sent-in-response-if-using-jsonxmlview-with-serialization

    My usage case is not exactly the same, but outputting json is stopping the FirePHP headers from appearing. If I turn off the parse extensions directive for json, the FirePHP headers appear as they should.