Last active
January 21, 2018 19:41
-
-
Save pascal08/305bb5be877262dfe21da9fc48cba877 to your computer and use it in GitHub Desktop.
Turn PHP CLI XDebug on and off from command line
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
function php_exists() { | |
if ! [ -x "$(command -v php)" ]; then | |
echo 'b'; | |
return 0; | |
fi | |
echo 'a'; | |
return 1; | |
} | |
function php_module_enabled() { | |
if ! [ php_exists ]; then | |
echo 'PHP Installation Not Found!'; | |
return 0; | |
fi | |
result=$(php -m | grep "$1"); | |
if [ "$result" != "$1" ]; then | |
return 0; | |
fi | |
return 1; | |
} | |
# Turn Xdebug on | |
function xon() { | |
configfile=$(php -i | grep -o -e "Loaded Configuration File => \(.*\)" | grep -oP "([A-Za-z]:[\\A-Za-z0-9.-_]*php\.ini)"); | |
sed -b '/^\s*;\s*zend_extension\s*=\s*php_xdebug\.dll/s/^\s*;\s*//' -i "$configfile"; | |
} | |
# Turn Xdebug off | |
function xoff() { | |
configfile=$(php -i | grep -o -e "Loaded Configuration File => \(.*\)" | grep -oP "([A-Za-z]:[\\A-Za-z0-9.-_]*php\.ini)"); | |
sed -b 's/^\s*zend_extension\s*=\s*php_xdebug\.dll/;&/' -i "$configfile"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment