Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Xdebug for PHP CLI

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 ?

like image 617
Eray Avatar asked Feb 16 '14 20:02

Eray


1 Answers

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.

like image 122
bazilio Avatar answered Oct 23 '22 23:10

bazilio