Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Xdebug Toggler for OSX

Xdebug is a must have extension for PHP, although the times you don't actually need it, it's a drag.

This simple script allows to toggle on and off Xdebug and is meant for anyone running PHP and Xdebug installed via Homebrew.

You can follow the OS X Apache Setup guide, divided in two parts, to get the perfect MAMP setup on OSX:

This script is inspired by the great sphp script. Which I highly suggest to install if you need to switch easily between php versions. However since it's been quite inactive I am now running and maintaning my own implementation. You can get it from

Quick Installation

curl -L > /usr/local/bin/xdebug-toggle

Installation with clone

git clone

Add /usr/local/bin to your $PATH. If you use the Bash shell, you can do this by running this command:

echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.bashrc

You may need to restart your shell for this to take effect, or refresh it with source ~/.bashrc.

If you want the global command then run:

cd xdebug-osx
ln -s `pwd`/xdebug-toggle /usr/local/bin/xdebug-toggle

Make sure xdebug-toggle is executable

chmod +x /usr/local/bin/xdebug-toggle

Xdebug installation and configuration

Homebrew does not provide a keg for Xdebug anymore, so you must install Xdebug extension via pecl

pecl channel-update
pecl install xdebug

xdebug-toggle needs a file called ext-xdebug.ini in brew's php conf.d directory to work, which must contain, at least, the following:


Make sure that php.ini doesn't contain this line too.

It's recommended to keep al xdebug config in this file, as an example:




xdebug-toggle                            # outputs the current status
xdebug-toggle on                         # enables xdebug
xdebug-toggle off                        # disables xdebug
xdebug-toggle on|off --no-server-restart # toggles xdebug without restarting apache or php-fpm