42

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?

gagneet
  • 35,729
  • 29
  • 78
  • 113

6 Answers6

31

xdebug has Code Coverage Analysis.

Check this chapter of the PHPUnit Manual

Samuel Dauzon
  • 10,744
  • 13
  • 61
  • 94
Christian C. Salvadó
  • 807,428
  • 183
  • 922
  • 838
6

See our 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
  • 93,541
  • 22
  • 172
  • 341
  • 2
    Downvoter (flagger): Your specific objection to this answer? – Ira Baxter Jul 12 '11 at 21:27
  • 3
    +1 to counter-balance the -1, seeing that this is NOT spam, since it is clearly stated as promotional, and actually gives a relevant answer. – SirDarius Aug 11 '11 at 14:11
  • 1
    This product uses a Windows-based tool to instrument the application source code. The instrumented code can run anywhere there's a PHP interpreter, e.g., your hosted web site. The results report generation and display is done by a Java program. – Ira Baxter May 10 '12 at 05:18
  • 1
    ... it is worth reporting that it operates under Linux using Wine quite effectively. – Ira Baxter Sep 03 '12 at 13:48
  • The registration form on their page is a hell – Johannes Reiners Sep 18 '12 at 09:09
3

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

Brian Fisher
  • 23,519
  • 15
  • 78
  • 82
2

Xdebug can do code coverage reporting, and Phing, a build utility, can automate running coverage reports (http://devzone.zend.com/article/2955).

Will
  • 24,082
  • 14
  • 97
  • 108
  • 6
    what does Phing have to do with code coverage? It's a build tool for launching many other tools. – Radek Simko Aug 29 '12 at 08:31
  • +1 @RadekSimko that's exactly what it is. I would prefer PHPUnit which can be used to run Selemium as well – Bhargav Nanekalva Mar 25 '15 at 10:37
  • I was merely trying to point out that mentioning Phing is very misleading when answering the original question (which was my reason for the downvote). – Radek Simko Mar 25 '15 at 20:44
  • @RadekSimko, I fixed my answer to be a bit more clear. Care to remove your downvote? I definitely see your point; I answered that about 5 years ago :) – Will Mar 26 '15 at 20:50
  • @Will Like to see people learning over time, downvote removed. ;) – Radek Simko Mar 28 '15 at 15:04
2

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

CanSpice
  • 34,814
  • 10
  • 72
  • 86
troelskn
  • 115,121
  • 27
  • 131
  • 155
2

Zend Studio ships with code coverage tools out the box.

cparrish817
  • 351
  • 4
  • 10
  • I'd be interested in checking code coverage with Zend Studio, but haven't found anything really on the net, could you provide some reference? – Preexo Apr 04 '14 at 15:03