Skip to content

w00fz/xdebug-osx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 https://gist.github.com/w00fz/142b6b19750ea6979137b963df959d11

Quick Installation

curl -L https://raw.githubusercontent.com/w00fz/xdebug-osx/master/xdebug-toggle > /usr/local/bin/xdebug-toggle

Installation with clone

git clone git@github.com:w00fz/xdebug-osx.git

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.php.net
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:

zend_extension="xdebug.so"

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]
zend_extension="xdebug.so"

xdebug.var_display_max_depth=24
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.remote_connect_back=1

Usage

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

License

LICENSE