In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about PHP continuous integration tools, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.
The concept of continuous integration
The concept of continuous integration is put forward in modern software engineering, and it was first seen in agile development methodology. Master Martin Fowler defines continuous integration as a software development practice, that is, team development members often integrate their work, usually each member integrates at least once a day, which means that multiple integrations may occur every day. Each set is verified by automated builds (including compilation, release, and automated testing) to find integration errors as soon as possible. Many teams find that this process can greatly reduce integration problems and enable teams to develop cohesive software more quickly.
The continuous integration tools in PHP are described below:
PHPUNIT
First of all, PHPUNIT is a sharp tool for unit testing in PHP, and the project address is http://www.phpunit.it. it
It can automatically run the unit test code you write and give the result of whether it passes or not. The installation steps are as follows, and you can install using PEAR in PHP:
Sudo apt-get install php5-curl php-pear php5-dev sudo pear upgrade pear sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear install phpunit/PHPUnit
After that, you can execute phpunit in the following format from the command line:
The php file name of the Phpunit unit test. php
In addition, you can execute the following command to generate an coverage report for the unit test:
Phpunit-- coverage-html.. / CodeCoverage
This will generate a unit test coverage report in the specified directory, such as in this example, in the directory CodeCoverage, as shown in the following figure:
Click ▲ to see the big picture.
If you click on each PHP file in the figure above, you can also see the unit test coverage of each file, as shown in the following figure:
Click ▲ to see the big picture.
From the figure above, you can see the unit test coverage of the called method in each PHP file, and you can also see which lines of code have been covered by the unit test and which have not been covered (green means it has been covered, orange means it has not been covered), as shown in the following figure:
Click ▲ to see the big picture.
PHP CodeSniffer
PHP CodeSniffer is a PHP code style detector, it according to the pre-set PHP coding style and rules, to check the application code style, built-in ZEND,PEAR coding style rules, of course, developers can also customize. The address of the project is: http://pear.php.net/package/PHP_CodeSniffer/redirected. The installation method is as follows:
Sudo pear install PHP_CodeSniffer phpcs-- standard=Zend c:\ phpcode
Phpcs-standard specifies to use Zend's recommended code style standard for checking. * one parameter is the directory where the PHP file to be checked is located. After running, one of the results of the check is shown in the following figure:
▲ Click to see a larger image
PHP Depend
PHP Depend (http://pdepend.org/) is a tool for static code analysis in PHP. It can be used to check the size and complexity of the code in your PHP project. The installation method is as follows:
Sudo pear channel-discover pear.pdepend.org sudo pear install pdepend/PHP_Depend-beta
An example of use is as follows:
Pdepend-jdepend-xml=../jdepend.xml-jdepend-chart=../dependencies.svg-overview-pyramid=../overview-pyramid.svg
It will generate a XML file and two SVG graphics files. The XML file illustrates the interdependent calls (references) of the PHP files in the project and the lines of code for each method, function, and class. An example is as follows:
The meaning of noc is the line book of the code of the class, nof is the number of lines of code of the function, noi is the number of lines of interface code, and nom is the number of lines of code of the method method.
Next, let's take a look at a generated SVG diagram, which is as follows:
This diagram reflects the dependency measurement of packages in the project. The basic theory comes from the measurement of module dependence and stability in software introduced by Robert C. Martin (http://www.objectmentor.com/resources/articles/oodmetrc.pdf)). Among them, the following concepts are mentioned:
Afferent Couplings (Ca)
Depends on the number of other package of the package being analyzed to measure the responsibilities of the pacakge.
Simply put, how many other packages or modules have called the parsed package or module.
Efferent Couplings (Ce)
The number of other package that the class of the parsed package depends on to measure the independence of the package.
That is, how many other packages it calls.
Abstractness (A)
The ratio of the abstract classes and interfaces in the analyzed package to the number of all classes in the package, with a value range of 0-1. If the value is 0, it proves that there are no abstract classes in the package, only classes that specifically implement logical methods. If the value is 1, there are only abstract classes or interfaces in the package.
Instability (I)
I=Ce/ (Ce+Ca), which is used to measure the instability of package, with values ranging from 0 to 1. Istabil0 is the most stable and Iron1 is the most unstable.
Distance (D)
Used to measure the balance between stability and abstractness of package. As you can see, the ideal situation is that AbeliI is closer to 1, so that a balance between abstractness and stability can be achieved.
In addition, introduce the meaning of another picture generated in php depend, as follows:
In this diagram, the top ANDC represents the average number of other classes inherited, that is, how many classes in the project inherit from other classes; AHH is the number of hierarchies that inherit other classes. CALLS is the total number of times the method was called, and FANOUT is the number of types referenced by the class. CYCLO is cyclomatic complexity (for more information on cyclomatic complexity resolution, please refer to (http://en.wikipedia.org/wiki/Cyclomatic_complexity)). LOC is the number of lines of code, NOM is the number of methods in the project, NOC is the number of classes in the project, and NOP is the number of packages in the project.
According to the division rules indicated in the figure above, the relevant data can be calculated. For more information, please refer to the php depend manual (detailed analysis of http://pdepend.org/documentation/handbook/reports/overview-pyramid.html)).
These are the PHP continuous integration tools, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.