views:

1886

answers:

6

Is there any code coverage tool available for PHP? I wish to check the code coverage of my code and API's written in PHP, but have not been able to lay my hands on any code coverage tool for PHP, as it is more of a server side language and dynamic in nature.

Does anyone know of a method by which code coverage for PHP can be executed?

A: 

Using Xdebug in combination with PHPUnit can give you code coverage analysis.

Brian Fisher
+5  A: 

xdebug has Code Coverage Analysis.

Check this chapter of the PHPUnit Manual

CMS
A: 

http://gcov.php.net/

I don't think it has anything to do with server side or dynamic.

tharkun
That's actually the code coverage statistics for the PHP Project itself. They use gcov since PHP is written in C...
CMS
+2  A: 

Spike PHPCoverage. Both SimpleTest and PHPUnit can easily be integrated with it, although PHPUnits support is there out-of-the-box.

troelskn
Isn't spike simply a wrapper around xDebug?
andrewdotnich
yes, it uses xdebug.
troelskn
A: 

See the PHP Test Coverage tool from Semantic Designs:

http://www.semanticdesigns.com/Products/TestCoverage/PHPTestCoverage.html

Very low overhead, handles huge systems of files, intuitive GUI showing coverage on specific files, and generated report with coverage breakdown at method, class and package levels.

Best of all, no requirement to install anything in the system being tested. No need for xdebug, etc., which means you don't have to argue with the sysadmin to do your testing.

You can use it with PHPUnit to get unit-test driven coverage. Or you can use it on your website to collect coverage from any functional testing approach/tools you may have.

Ira Baxter
+1  A: 

Phing can do code coverage reporting with xdebug (http://devzone.zend.com/article/2955).

Will
Phing. is. love.
analytik