in Code Snippet

Enable and disable Xdebug quickly on OS X homebrew php 7.1

Xdebug is a powerful tool for debugging PHP code, but it can be a memory hog when it is continuously turned on. Xdebug can be quickly enabled and disabled by creating simple custom scripts.

Download these shell files on your Mac, make them executable and you are good to go!

curl -L -o /usr/local/bin/disable-xdebug
curl -L -o /usr/local/bin/enable-xdebug
chmod +x /usr/local/bin/*able-xdebug

Now run enable-xdebug on your terminal to enable Xdebug and disable-xdebug to disable it.

Write a Comment


  1. Hi!
    I’m not sure in my solution, but for using Valet, I should update script in this way
    sed -i.default "s/^;zend_extension=/zend_extension=/" /usr/local/etc/php/7.2/php.ini
    valet stop
    brew unlink php
    valet use [email protected]
    echo "xdebug for php7.2 enabled"