Created
January 12, 2012 14:41
-
-
Save wesen/1600897 to your computer and use it in GitHub Desktop.
Selectively enable/disable Xdebug for different resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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