0

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.

Joseph
  • 2,737
  • 1
  • 30
  • 56
  • My site's still available: http://someguyjeremy.com/blog/using-firephp-to-debug-your-cakephp-app – jeremyharris Dec 17 '12 at 15:59
  • Do you see Firephp headers in the firebug responses? At the very least with Firebug you can inspect the headers. Look for lots of `X-Wf-X-X-X-XX` headers. – jeremyharris Dec 17 '12 at 16:27
  • Also make sure the `Net` tab is enabled. – jeremyharris Dec 17 '12 at 16:35
  • @jeremyharris I don't know what the problem was yesterday. When I clicked on your site it was redirecting to a strange url (with the numbers 404 in the actual domain name if I remember correctly) which was subsequently timing out. Anyway, it's working ok now so I have updated the post with the correct URL. – Joseph Dec 18 '12 at 02:17
  • @jeremyharris I have updated the post with new details. I discovered that this problem is only happening when I am requesting an ajax action that is being routed through `outer::parseExtensions('json');` -- I think that this is the same bug as reported at http://cakephp.lighthouseapp.com/projects/42880/tickets/107-firephp-messages-are-not-sent-in-response-if-using-jsonxmlview-with-serialization but I'm not exactly sure. What do you think? – Joseph Dec 18 '12 at 02:19
  • the old domain was 42pixels.com, but all links 301 to the new domain. Oh well. That ticket only applies if you're using the automatic serialization, which if you have a view you're not. Are any of the `X-Wf` headers being sent (or better yet post/bin the request/response that you get)? – jeremyharris Dec 18 '12 at 15:07
  • @jeremyharris If I make the Ajax request via `controller/filter.json` (with `Router::parseExtensions('json');` enabled then there are no `X-Wf` headers but the Content-Type is set to `application/json`. If I disable `Router::parseExtensions('json');` and make the request to `controller/filter` then the `X-Wf` headers ARE generated but the Content-Type is `text/html`. I'm using PHP's `json_encode()` for the output in the view in both cases. – Joseph Dec 19 '12 at 02:04
  • @jeremyharris BTW, the vendor import of `FirePHP.class.php` mentioned in your blog post doesn't seem to be necessary with the latest DebugKit as it seems to use it's own internal instance of FirePHP. – Joseph Dec 19 '12 at 02:06
  • thanks, I'll update the post! I also fixed that redirect issue you mentioned. If there are no `X-Wf` headers in the response, that means that debug kit isn't even sending anything to firebug which sounds like a bug in DebugKit. It could be related to the one you posted (though it's not specifically that one). – jeremyharris Dec 19 '12 at 15:01
  • @jeremyharris Ok, well, I've posted what I'm experiencing on the Lighthouse bug ticket so hopefully someone will be able to tell me if it's the same bug or not. If it isn't, I'll open a new one. Nobody else has contributed to this question so if you'd like to answer it to confirm that I'm doing everything right and that it sounds like a bug, I will happily mark it as the correct answer :-) – Joseph Dec 20 '12 at 03:14
  • Your ticket says that you *are* using serialization when you're not. Might want to correct that so there's no confusion :) As for answering, you did all the work debugging the problem! I'd suggest you put an answer, add the ticket link, and accept it so future people know what's up. – jeremyharris Dec 20 '12 at 15:09
  • @jeremyharris - ah, I thought using json_encode was tantamount to using serialization. I've updated the ticket to clarify now. I've also 'answered' my questions as per your suggestion. Thanks and Merry Christmas! – Joseph Dec 21 '12 at 02:24

1 Answers1

1

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.

Joseph
  • 2,737
  • 1
  • 30
  • 56