Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PHP code coverage QuickStart

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

There are no pictures in the article. Please download the full version at the following address:

Http://down.51cto.com/data/413138

= split line =

1. What is php code coverage? There are indeed many code coverage tools for the java class, but very few for php. This is a code coverage tool for php code that I came across by accident.

In a word:

PHP_CodeCoverage is a library that provides collection, processing, and rendering functionality for PHP code coverage information.

2. Install the prerequisite PHP 5.2.7 (or later) is required but PHP 5.3.8 (or later) is highly recommended.

Xdebug 2.0.5 (or later) is required but Xdebug 2.1.2 (or later) is highly recommended.

Here I have introduced the installation under windows and linux, but it is more or less the same.

3. Installation under Windows 1) set up the LAMP environment first, there is no need to say much about this, there are a lot of things on the Internet

2) install xdebug and load it as zend_extension in php.ini (verify success with phpinfo)

Comment out; extension=php_xdebug.dll.

3) install pear and visit http://pear.php.net/go-pear.phar for download

Install using go-pear.bat (in the php.exe directory)

In the php.exe directory, enter pear help in cmd and the help message appears, then the installation is successful.

4) install PHP_CodeCoverage

Download: https://github.com/sebastianbergmann/php-code-coverage

Pear channel-discover pear.phpunit.de

Pear channel-discover components.ez.no

Pear install phpunit/PHP_CodeCoverage

5) copy two auto to the www root directory

6) modify the corresponding auto of php.ini to the above two php files

7) restart server

The directory structure after successful installation is as follows:

The files under www are as follows:

The above two are the configurations in the php.ini corresponding to the auto file

The following two are the php being tested

4. Installation under Linux 1) install xdebug and load it in zend_extension in php.ini (verify success with phpinfo)

Comment out; extension=php_xdebug.dll.

2) install pear

Wget http://pear.php.net/go-pear.phar

Php go-pear.phar

3) install PHP_CodeCoverage

Pear channel-discover pear.phpunit.de

Pear channel-discover components.ez.no

Pear install phpunit/PHP_CodeCoverage

The directory structure after success is as follows:

4) copy two auto to the www root directory

5) modify the corresponding auto of php.ini to the above two php files

6) restart server

Note: if install cannot be installed, please run pear clear-cache first

5. The file analysis of the two auto is in the www root directory.

The last line is the output of the report, which is generated by default in the www root directory. Windows should be fine. Permissions need to be considered under linux, which can be placed somewhere else, such as / tmp/report.

6. Report style

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report