Asynchronous client requests in Tracy (AJAX)

Notice: This thread is very old.
Nette Core | 1283


We have the Tracy bar now. In the bar we have many panels with a per-request static data. Possibility to send asynchronous requests (AJAX) from panel to the application moves usability to next level. Imagine following scenarios:

  • SQL panel allows you to run queries and display the result
  • some next panel helps you to delete file or purge whole (temporary) directory on one click

This feature needn't be limited for Bar panels only. For example, bluescreen panel can use it for additional source code lines loading (as Github do it).

Why add code directly into Tracy

Described features can be implemented by user more or less out of Tracy. But there are things of which must be cared:

  • security – asynchronous calls for development must be automatically forbidden in production mode
  • client javascript – it isn't to trivial write a well AJAX handler
  • helpers – (e.g. for escaping) are needed


I prepared a pull request with the implementation and I would like to discuss it here or on Github by comments.

  • naming conventions – I'm prepared to receive better names for everything :)
  • javascript – I'm not so advanced javascripter, advices are very welcomed

Some particular problems:

  • AJAX request from a panel must be somehow identified by Tracy. Tracy must be capable pass the request to the same panel on the server side. I'm using IAsyncHandler::setHandlerId() for it but I don't like it much.
  • Should be handlers wrapped by class out of Debugger? E.g. Debugger::getAsyncHandlersStorage()->add($handler)?
  • Where to place Javascript? Is it fine in the bar.js for now?

Tests and documentation will be added.

AJAX panel example

The linked PR contains working bar panel named AJAX. It is added to Tracy bar three times and when you open it, you can click to refresh link. Panel will be updated by current timestamp by AJAX call. You can try it by:

cd web-root
git clone -b rfc-ajax rfc-ajax