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

0.4.1 2025-07-24 18:58 UTC

This package is auto-updated.

Last update: 2025-07-25 12:43:37 UTC


README

Build Status Latest Version License Downloads

๐Ÿš€ 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

  1. Add a ruleset.xml file to your project or use the one provided in this package.
  2. 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.