Skip to content

Instantly share code, notes, and snippets.

@wesen
Created January 12, 2012 14:41
Show Gist options
  • Select an option

  • Save wesen/1600897 to your computer and use it in GitHub Desktop.

Select an option

Save wesen/1600897 to your computer and use it in GitHub Desktop.
Selectively enable/disable Xdebug for different resources
$uri = request_uri();
$DISABLE_XDEBUG_DIRS = array("/js/", "/resource/", "/rest/", "/css/", "/item/");
$ENABLE_XDEBUG_DIRS = array();
$disableXdebug = false;
$enableXdebug = false;
$dir = "/";
foreach ($DISABLE_XDEBUG_DIRS as $dir) {
if (str_starts_with($uri, $dir)) {
$disableXdebug = true;
break;
}
}
if (!$disableXdebug) {
foreach ($ENABLE_XDEBUG_DIRS as $dir) {
if (str_starts_with($uri, $dir)) {
$enableXdebug = true;
break;
}
}
}
if ($disableXdebug) {
setcookie("XDEBUG_SESSION", "hmpf", time() + 2600, get_relative_path($dir));
} else if ($enableXdebug) {
setcookie("XDEBUG_SESSION", Configuration::GetConfig("xdebug.idekey", "intellij"), time() + 2600, get_relative_path($dir));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment