Skip to content

Instantly share code, notes, and snippets.

@romaricdrigon
Created November 5, 2013 11:55
Show Gist options
  • Save romaricdrigon/7317993 to your computer and use it in GitHub Desktop.
Save romaricdrigon/7317993 to your computer and use it in GitHub Desktop.
Symfony2 DebugToolbar Bookmarklet
javascript:(function(){var e=window.location.href.match(/.+\/app_dev\.php/);if(e){var t=new XMLHttpRequest;t.open("GET",document.location,false);t.send(null);var n=t.getResponseHeader("X-Debug-Token");var r=e[0]+"/_profiler/"+n;window.location.href=r}})()
/*
For a given Symfony2 app page, being in DEV mode (app_dev.php),
Open (or redirect) to the corresponding web debug profiler
*/
javascript:(function() {
// Get base url
var url = window.location.href.match(/.+\/app_dev\.php/);
if (url) {
// We can't directly get headers - we have to make a new request to get them
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var token = req.getResponseHeader('X-Debug-Token');
var debugUrl = url[0] + '/_profiler/' + token;
// uncomment to open a pop-up
//window.open(debugUrl);
// or redirect
window.location.href = debugUrl;
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment