9

I'm using XAMPP on Mac OS, trying to use PHPUnit's code coverage checks, which require XDebug. The xdebug.so file comes with XAMPP so I've enabled Xdebug for PHP:

// /Applications/XAMPP/xamppfiles/etc/php.ini
[xdebug]
zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.remote_enable=1

Now, when I check from the web server, there is an Xdebug section inside the output from phpinfo().

But when I'm trying to check code coverage I get an error:

$ phpunit --coverage-html report
PHPUnit 3.7.31 by Sebastian Bergmann.

The Xdebug extension is not loaded. No code coverage will be generated.

I think CLI using different php.ini than Apache . To find which php.ini file CLI is using I did this:

$ php -i | grep "php.ini"
Configuration File (php.ini) Path => /etc

But there is no /etc/php.ini so I copied one over:

$ sudo cp /Applications/XAMPP/xamppfiles/etc/php.ini /etc/php.ini

Now I'm checking php -m for modules, but there is no Xdebug and I'm getting this error:

$ php -m
Failed loading /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so:  dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so, 9): Symbol not found: _zend_execute_ex
  Referenced from: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
  Expected in: flat namespace
 in /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
[PHP Modules]
bcmath
bz2
...

Here is the content of my php.ini file (check last lines.)

Can you tell me how I can enable Xdebug for PHPUnit and CLI ?

5
  • Strange, the last error looks like a binary incompatibility though. Commented Feb 16, 2014 at 20:29
  • 1
    Temporary solution : I've renamed /usr/bin/php to /usr/bin/phpp and then ln -s /Applications/XAMPP/xamppfiles/bin/php /usr/bin/php Commented Feb 16, 2014 at 21:23
  • I never understood why people use those xampp packages. I saw so many problems with the setup that I doubt very much that xampp really makes things easier. It might appear like a good thing to have a single package offering all you need for basic web development. But it shows again and again that using the packages provided by the normal distribution resources cause less problems since they are better integrated into the systems. That said I have to point out that these benefits are not available for MS-Windows or MaxOSX users, since there is no such elegant concept for these systems. Commented Feb 16, 2014 at 21:32
  • Your temporary solution isn't really temporary, its the correct answer (+1). Your php command was using the built-in Mac OS X binary, which had a different build than what your xamp binary required. For people with similar issues run which php to ensure you're executing the expected binary on the command line. Commented Feb 23, 2015 at 18:27
  • Your temporary solution is dangerous and will be undone at next OS upgrade. The answer below should be accepted, and you should always leave system files (including /etc/php.ini alone!) Commented Mar 17, 2017 at 23:21

1 Answer 1

1

What which php output you have?

Looks like you're using system-wide php instead of XAMPP version. To use XAMPP add PATH=/Applications/XAMPP/xamppfiles/bin/:PATH to your ~/.bashrc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.