Skip to content

Instantly share code, notes, and snippets.

@esolitos
Created April 29, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esolitos/4b7a9919454c7eccab2e to your computer and use it in GitHub Desktop.
Save esolitos/4b7a9919454c7eccab2e to your computer and use it in GitHub Desktop.
Enable XDebug on OS.X

Each machine that has Apple's XCode installed has also XDebug, so we don't need to add it with pecl, brew, macports, or any similar package manager, simply add it to your php.ini file!

To simply do it, I give you this one-liner solution:

  sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'

If you're familiar with bash you probably have already understood, but if you need extra info about what's happening (and you should) there's the explaination:

  • Find the native Xdebug extension that comes with Xcode: find /usr/lib/php/extensions -name "xdebug.so"
  • Asks php which config file is loaded: php -qr "echo php_ini_loaded_file();"
  • Adds the Xdebug extension path in the config file (echived using echo and >>)
  • Restarts apache. apachectl restart

source: http://stackoverflow.com/questions/19579401/php-xdebug-on-os-x-10-9-mavericks

@esolitos
Copy link
Author

Note: Additional *.ini files are usually loaded by apache from this directory:
/Library/Server/Web/Config/php

@alxndrhi
Copy link

Keep in mind apples xdebug is pretty old. Some things dont work.

btw. I have a little xdebug settings starter file: https://gist.github.com/alxndrhi/8719355bf6e11676d71b
Maybe you like some of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment