PHP Xdebug on OS X 10.9 Mavericks

greyfox picture greyfox · Oct 25, 2013 · Viewed 56.7k times · Source

I'm having issues setting up my PHP development environment on OS X after installing OS X 10.9 Mavericks.

Here is the command I am using to install.

sudo pecl install xdebug

downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

Anyone have a solution or a workaround?

Answer

Creaforge picture Creaforge · Dec 16, 2013

The fast copy-paste way

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

This command do the following :

  • Finds the native Xdebug extension that comes with Xcode
  • Asks php which config file is loaded
  • Adds the Xdebug extension path in the config file
  • Restarts apache.

Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.

Before launching the command, make sure Xcode command line tools are installed : xcode-select --install