pekral / phpcs-rules
Custom ruleset for PHP_CodeSniffer (PHPCS) with additional rules and configuration, based on Slevomat Coding Standard. Helps to enforce consistent code style and best practices in PHP projects.
Fund package maintenance!
pekral
Installs: 3 184
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 17
Requires
- php: ^8.4
- slevomat/coding-standard: ^8.19.1
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-07-25 12:43:37 UTC
README
๐ Introduction
phpcs-rules is an extensible package of custom rules for PHP_CodeSniffer (PHPCS), based on the Slevomat Coding Standard. It helps you maintain consistent code style and high code quality in your PHP projects.
๐ฆ Installation
composer require --dev pekral/phpcs-rules
โ๏ธ Usage
- Add a
ruleset.xml
file to your project or use the one provided in this package. - Run PHPCS with this ruleset:
vendor/bin/phpcs --standard=vendor/pekral/phpcs-rules/ruleset.xml src/
๐ Usage Examples
Code check
vendor/bin/phpcs --standard=vendor/pekral/phpcs-rules/ruleset.xml src/
Automatic fix
vendor/bin/phpcbf --standard=vendor/pekral/phpcs-rules/ruleset.xml src/
Example configuration (ruleset.xml)
<?xml version="1.0"?> <ruleset name="Custom PHPCS Rules"> <rule ref="vendor/pekral/phpcs-rules/ruleset.xml"/> <!-- Your custom rules here --> </ruleset>
โ๏ธ Configuration
- Rules can be extended and customized in
ruleset.xml
. - Supports PHP 8.4+.
- Easy integration with CI/CD (GitHub Actions, GitLab CI, ...).
โ FAQ
Q: How do I add a custom rule?
A: Add it to your ruleset.xml
or extend this package.
Q: How do I run PHPCS only on specific folders?
A: Adjust the path in the PHPCS command, e.g. src/
, app/
.
Q: How can I contribute? A: Open an issue or pull request on GitHub.
๐ Further Resources
๐ License
This package is licensed under the MIT license.