Apr 18, 2018
0
Level 5
XDebug MacOS Toggle using Valet with XDebug installed via PECL
I was using xdebug-osx to toggle XDebug on and off but after reinstalling php I was unable to install XDebug through homebrew and forced to install using PECL so this is what I came up with to be able to toggle it on and off.
Hopefully someone else will find this useful.
function xdebug()
{
if [[ == "on" ]]; then
tput setaf 2; echo "Enabling XDebug..."
sed -i -e 's/#zend_extension=\"xdebug.so\"/zend_extension=\"xdebug.so\"/g' /usr/local/etc/php/7.2/php.ini && rm /usr/local/etc/php/7.2/php.ini-e && valet restart
elif [[ == "off" ]]
then
tput setaf 2; echo "Disabling XDebug..."
sed -i -e 's/zend_extension=\"xdebug.so\"/#zend_extension=\"xdebug.so\"/g' /usr/local/etc/php/7.2/php.ini && rm /usr/local/etc/php/7.2/php.ini-e && valet restart
fi
}
Edit: seems $1 has been stripped from the if statements, no idea why but you'll want to add them back.
Please or to participate in this conversation.