PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
squizlabs/php_codesniffer stats
- Downloads
- 287.6M
- Stars
- 10,710
- Open Issues
- 289
- Forks
- 1,473
PHP_CodeSniffer Package Summary
Overview
PHP_CodeSniffer is a crucial tool for maintaining code quality and consistency, equipped with two primary scripts: phpcs
for tokenizing PHP, JavaScript, and CSS files to detect coding standard violations, and phpcbf
for automatically correcting these violations. This package helps ensure that your project adheres to a specified coding standard, enhancing readability and maintainability.
Key Features
- Tokenization of Multiple Languages: PHP, JavaScript, and CSS.
- Automatic Code Correction: Utilize
phpcbf
to automatically fix code standard violations. - Compatibility: Requires PHP 5.4.0 or higher, with specific sniffs possibly requiring additional tools.
- Configurability: Supports custom configuration files for team or CI server integrations.
- Multiple Installation Methods: Installable via Phar files, Composer, Phive, PEAR, or directly from the Git repository.
Installation
- Phar Files:
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.pharcurl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar# or via wgetwget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.pharwget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
- Composer:
composer global require "squizlabs/php_codesniffer=*"
- Phive:
phive install phpcsphive install phpcbf
- PEAR:
pear install PHP_CodeSniffer
- Git Clone:
git clone https://github.com/squizlabs/PHP_CodeSniffer.git
Usage
Run PHP_CodeSniffer using:
phpcs /path/to/code-directoryphpcbf /path/to/code-directory
Specify coding standards with the --standard
option:
phpcs --standard=PSR12 /path/to/code-directory
Documentation and Support
- Documentation: Available on the GitHub wiki.
- Issue Tracking: Submit bugs or feature requests via the GitHub Issue Tracker.
- Community Chat: Join the conversation on Gitter.
Important Note
This repository has been abandoned. Its successor is PHPCSStandards/PHP_CodeSniffer. For more details, see issue #3932.
PHP_CodeSniffer adheres to semantic versioning with detailed guidelines for each version type (MAJOR, MINOR, PATCH), ensuring consistent and predictable updates.