2016 latest wamp2.5+windows 10 installation coedsgniffer code format check:

Source: Internet
Author: User
Tags coding standards pear zend checkstyle


14:59 2016/1/11
2016 latest wamp2.5+windows 10 installation coedsgniffer code format check:
Note the issue:
1. Manual installation of 2.5.0 and pear installation methods are successful, but no reflection of the implementation, and finally found that the issue is a version problem, and finally the manual installation of 2.4.0 success!
: http://pear.php.net/package/PHP_CodeSniffer/download/2.4.0
2. Add environment variable: d:\dev\tools\PHP_CodeSniffer-2.4.0
3. The following @[email protected] I did not find in the 2.4.0, in the 1.4.5 there is, should be the version of the difference.
4. Related directories make corresponding changes according to your own directory
Windows install PHP codesniffer
1. Download php_codesniffer/package/php_codesniffer-2.4.0.tgz
2. Extract to Directory: d:\dev\tools\PHP_CodeSniffer-2.4.0
3. Modify Script/phpcs.bat file
1) @[email protected] Replace with local PHP execution file path: D:\xampp\php\php.exe
2) @[email protected] Replace with PHP codesniffer directory: d:\dev\tools\PHP_ CodeSniffer-2.4.0
3) @[email protected]\phpcs Replace with phpcs script path: d:\dev\tools\PHP_CodeSniffer-2.4.0\scripts\ Phpcs
Open command line: Run Phpcs-i.
the installation was successful.
Execute phpcs+ file name will be prompted, the error needs to be modified, the error after the ' [x] ' inside ' x ' means that phpcs can be automatically repaired, Go to the Phpcd.bat sibling directory under the Phpcbf.bat also do phpcd.bat within the changes,
but note: is D:\DEV\TOOLS\PHP_CODESNIFFER-2.4.0\SCRIPTS\PHPCBF, The word at the end.

If you don't want to include a warning message (WARNING) in the output's check results, you can add the-n parameter to Phpcs. By default, Php_codesniffer will output a list of all error and warning messages after the file is checked, usually for a long time, especially if the list is long and fast when checking for more files, and you don't see anything at all. At this point you may need to know how many error and warning messages each file has, and you can use the--report=summary parameter. $ phpcs--report=summary/path/to/code
In addition, Php_codesniffer can output the inspection results in a format similar to xml,csv and Checkstyle output, which makes it easier for you to analyze the results of the inspection in your own scripts or to provide support for checkstyle applications.

$ phpcs--report=checkstyle/path/to/code
$ phpcs--report=csv/path/to/code
$ phpcs--report=checkstyle/path/to/code

Note: When you export the check results in CSV format, the first line of the output indicates the order in which the result information is checked (that is, which column is the information).
In addition, Php_codesniffer does not output any information during processing until the end of the processing output check results. When working with more files, it may take a long time to wait, and if you want to know what's going on in the process, you can take the-v parameter when executing php_codesniffer, so php_ Codesniffer outputs the name of the file currently being processed, the number of rows and identifiers that are included in the process.
Setting the relevant configuration options for Php_codesniffer

Php_codesniffere has some configuration options available, and some encoding standards can only be used if configuration options are set. To set a hp_codesniffer configuration option, you can use:

$ phpcs--config-set <option> <value>

You can use the following command to remove any of the configuration options so that it reverts to the initial value.

$ phpcs--config-delete <option>

Use the following to view the current settings for configuration options

$ phpcs--config-show

The following is a list of configuration options for Php_codesniffer and how to set it up:

Default_standard the default encoding standard
Report_format default Error Reporting format
Show_warnings whether the warning (WARNING) information in the error report is displayed by default
Tab_width The default tab width is equal to a few spaces
Zend_ca_path configuration options used by the Zend encoding standard, pointing to the path where Zend Code Analyzer (Zend Encoding Analyzer) is located

By default, Php_codesniffere uses pear as the encoding standard if the command line does not specify an encoding standard. You can modify the default encoding standard by using the following commands.

$ phpcs--config-set Default_standard Zend


By default, if the command line does not provide a parameter for the report output format, Php_codesniffere uses the full error report format to output the check results. You can modify the default output format of the check results by using the following commands.

$ phpcs--config-set Report_format Summary


By default, php_codesniffere output will output error and warning messages, you can either remove the warning message on the Phpcs-n band, or you can set the show_warnings to show or not display by default.

$ phpcs--config-set show_warnings 0


By default, Php_codesniffere does not replace the tab in the checked file with a space. Specify a tab width on the command line you can use Php_codesniffere to replace the tab in the checked file when checking. You can set Config-set to make php_codesniffere default to replace tab into spaces.

$ phpcs--config-set tab_width 4


Note: When the Php_codesniffere has been set to default to replace tab into spaces, specifying tab_width to 0 on the command line causes Php_codesniffere to stop replacing tab.

The Zend encoding standard includes a sniff using the Zend Code Analyzer (Zend Encoding Analyzer), using the Zend_ca_path configuration option to tell Zend the path to Code Analyzer.

$ phpcs--config-set Zend_ca_path/path/to/zendcodeanalyzer
Specifies the file type (extension) to be checked by the Php_codesniffer

By default, Php_codesniffer checks. Inc and. PHP files. In other words, if you specify a directory for Php_codesniffer to check, only files with the extension of INC and PHP will be checked. You can use the extensions parameter to set which type of file name extension in the command line requires a php_codesniffer check. $ phpcs--extensions=php/path/to/code Only check files in this directory that have PHP extensions

$ phpcs--extensions=php,inc,lib/path/to/code Check all files in this directory with the php,inc,lib extension

Note: This parameter does not apply if you specify a file (not a file directory) directly on the command line, because in this case Php_codesniffer will ignore all file extensions.

$ phpcs--extensions=inc sgl_06x/www/index.php sgl_06x/www/rpc/server.php Although an inc is specified, the php file is still checked

Ignoring the file extension is an attribute of Php_codesniffer and is the only way to check for a file that does not have an extension. If you give Phpcs a file directory as a parameter, then the file in this directory with no extension will not be checked, if you want to check, only one check.

Let Php_codesniffer ignore some of these special files while checking a large number of files

When php_codesniffer a large number of files, we may not want to php_codesniffer check some of these special files. You can use the Ignore parameter to specify the matching mode of the file name, and all files that match the schema will be ignored without checking.

$ phpcs--ignore=*/tests/*,*/data/*/path/to/code


In fact, there are some more features, but I think there is no need to see, will use the above almost, or scare people no one used .... It's a good thing! Well, it's good for the company.
Here to remind, do not look at the error report is English gave up Kazakhstan, in fact, not difficult, really not Google
Special Recommended Reference: Http://www.educity.cn/wenda/23493.html


The following installation succeeded but did not have any reflection, finally found that the problem is a version problem, and finally the manual installation of 2.4.0 succeeded!
Installing Php_codesniffer
If you have PHP and pear installed on your Web server, you can install Php_codesniffer by running the following command directly.
$ pear Install Php_codesniffer
After installation, you can call Php_codesniffer to check the code by typing command phpcs at the command line, by default, Php_codesniffer uses the pear
Coding standards; You can try it now to check if your code conforms to the coding standards, such as:
$ phpcs/path/to/code/yourfile.php
If you want to check a directory, you should use the following command:
$ phpcs/path/to/code
How to use Php_codesniffer
The main program that uses Php_codesniffer is phpcs, and its specific use can be achieved by running the following command at the command line to obtain the relevant parameters of phpcs and
The appropriate usage information.
$ phpcs-h
Use Php_codesniffer to check files or file directories: The simplest way to use php_codesniffer is to pass a path directly to Phpcs. If the path is pointing to a file directory, then php_codesniffer checks the file directory and all the files in the directory. If you do not want to check all subdirectories, you can add the-l (locally) parameter so that it only checks the files in the current directory. $ phpcs/path/to/code/myfile.inc
$ phpcs/path/to/code/my_dir You can also specify multiple files or directories at the same time for php_codesniffer inspection.
$ phpcs/path/to/code/myfile.inc/path/to/code/my_dir Control Php_codesniffer Output Check Results
Recommendation: http://bbs.lampbrother.net/read-htm-tid-152445.html

2016 latest wamp2.5+windows 10 installation coedsgniffer code format check:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.