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?

6 Answers 6

31

xdebug has Code Coverage Analysis.

Check this chapter of the PHPUnit Manual

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

Comments

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.

5 Comments

Downvoter (flagger): Your specific objection to this answer?
+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.
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.
... it is worth reporting that it operates under Linux using Wine quite effectively.
The registration form on their page is a hell
3

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

Comments

2

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

1 Comment

Isn't spike simply a wrapper around xDebug?
2

Zend Studio ships with code coverage tools out the box.

1 Comment

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?
2

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

5 Comments

what does Phing have to do with code coverage? It's a build tool for launching many other tools.
+1 @RadekSimko that's exactly what it is. I would prefer PHPUnit which can be used to run Selemium as well
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).
@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 Like to see people learning over time, downvote removed. ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.