squizlabs/php_codesniffer
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The Squizlabs/PHP_CodeSniffer is a fantastic development tool known for maintaining the cleanliness and consistency of your code. In essence, it tokenizes PHP, JavaScript, and CSS files and detects violations of a predefined set of coding standards. Incorporating two PHP scripts - the 'phpcs' script that detects coding standard violations, and the 'phpcbf' script that automatically corrects such violations, PHP_CodeSniffer provides an unparalleled edge to the current development practices.
To get started with PHP_CodeSniffer, you can simply download the Phar files for each of the commands using curl or wget. You can use Composer, Phive, PEAR or Git to install it. For Composer, the command would be "composer global require 'squizlabs/php_codesniffer=*'" or you can include it in your composer.json
file. With Phive, you install PHP_CodeSniffer as a project tool using "phive install phpcs" and "phive install phpcbf". You can also install it with PEAR installer after ensuring you have installed PEAR, or download the source and run the commands directly from the Git clone. The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file or a directory against the PEAR coding standard, specify the file or directory's location with the command "phpcs /path/to/code/myfile.php" or "phpcs /path/to/code-directory". For checking against the PSR-12 coding standard, use the --standard
command line argument with the command "phpcs --standard=PSR12 /path/to/code-directory".
# here's an example of how to check a file against the PEAR coding standard
phpcs /path/to/code/myfile.php
# if you wish to check against the PSR-12 coding standard
phpcs --standard=PSR12 /path/to/code-directory
The detailed documentation for PHP_CodeSniffer is readily available on their GitHub Wiki page. You can access everything from configuration options, coding standard specifics to advanced usage tips on this page. Any issues, bug reports or feature requests can be submitted on the GitHub Issue Tracker for the project. For anyone eager to contribute to the project, you can refer to the CONTRIBUTING.md file for comprehensive information.