4
votes

I am trying to get Xdebug code coverage analysis for PHP working on the command line, but I get an undefined function error for code coverage functions. I am not using PHPUnit, and I'm not using an IDE. My text editor is Komodo Edit.

I am using:

  • Windows 8
  • PHP 5.4.12
  • Apache 2.2.4 (but command-line PHP)
  • WAMP

I downloaded Xdebug 2.2.4 for PHP 5.4 VC9 TS (64 bit) and followed the instructions on the Xdebug install page to configure my computer.

I changed the php.ini files in C:\wamp\bin\apache\Apache2.4.4\bin and C:\wamp\bin\php\php5.4.12 to have the following settings for xdebug:

zend_extension = c:\wamp\bin\php\php5.4.12\ext\php_xdebug-2.2.4-5.4-vc9-x86_64.dll

[xdebug]
xdebug.remote_autostart=on
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp/xdebug"
xdebug.idekey=xdebug
xdebug.remote_log="c:/wamp/tmp/xdebug/xdebug_remote.log"
xdebug.coverage_enable = on

I added XDEBUG_CONFIG="idekey=xdebug" to my environment variables. I then restarted WAMP.

When I try to call xdebug_code_coverage_started() from my script, I get

PHP Fatal error: Call to undefined function xdebug_code_coverage_started()

The same happens for any code coverage functions I try. However, var_dump(xdebug_get_headers()) works. My phpinfo shows xdebug.coverage_enable is on.

I have also tried:

  • not setting xdebug.coverage_enable (it defaults to on)
  • not setting XDEBUG_CONFIG
  • setting xdebug.remote_enable to off
  • not setting xdebug.idekey, xdebug.remote_log, and xdebug.remote_autostart

all with the same results.

How do I get PHP to recognize Xdebug code coverage functions?

1
Is this still relevant? If so, is the dll actually in the folder pointed to in php.ini? - Peter
@Peter Yes, that's where the dll is. - Eva
Hello maybe you have to add quote for c:\wamp\bin\php\php5.4.12\ext\php_xdebug-2.2.4-5.4-vc9-x86_64.dll like "c:\wamp\bin\php\php5.4.12\ext\php_xdebug-2.2.4-5.4-vc9-x86_64.dll" - dyachenko
The quotation around the .dll could be an issue. In XAMPP 1.7.3 on Windows 7 putting quotes around the .dll will cause issues. This could be the issue. - unixmiah

1 Answers

0
votes

Hers is an example XDebug for php 5.3 or higher:

[Xdebug] zend_extension="<path to php_xdebug.dll>" 
xdebug.remote_enable=1 
xdebug.remote_port="<the port for Xdebug to listen to>" 
(the default port is 9000) 
xdebug.profiler_enable=1 
xdebug.profiler_output_dir="<AMP home\tmp>"

try to get it to as close as possible and restart WAMP.