talira

PHP_CodeSniffer Standards Composer Installer Plugin

Composer plugin that registers installed PHP_CodeSniffer coding standards automatically

open sourceMITfree

The PHP_CodeSniffer Standards Composer Installer Plugin (dealerdirect/phpcodesniffer-composer-installer) makes coding standards installed with Composer usable by PHP_CodeSniffer without symlinks or manual configuration. It finds every installed package of type phpcodesniffer-standard, scans them and the project for rulesets, and sets PHP_CodeSniffer's installed_paths option. You add it as a dev dependency and allow it to run in composer.json's allow-plugins.

Problems it solves

  • make phpcs find the coding standards I installed with Composer
  • stop symlinking PHP_CodeSniffer rulesets by hand
  • set up WordPress Coding Standards for phpcs in a Composer project

Features

  • Finds installed phpcodesniffer-standard packages and their rulesets
  • Sets PHP_CodeSniffer's installed_paths automatically
  • Works with PHP_CodeSniffer 3.x and 4.x and Composer 2.2+

Limitations

  • Composer 2.2+ asks permission before it runs: it must be allowed in allow-plugins1
  • Needs PHP 7.2 or newer1

Alternatives

The same job

These do what PHP_CodeSniffer Standards Composer Installer Plugin does.

  1. PHP_CodeSniffer Detect and fix coding standard violations in PHP
  2. WordPress Coding Standards for PHP_CodeSniffer PHP_CodeSniffer rules that enforce WordPress coding conventions
  3. laminas-coding-standard The Laminas Project's PHP_CodeSniffer coding standard ruleset, built on PSR-12
  4. Easy Coding Standard (ECS) Runs PHP_CodeSniffer and PHP-CS-Fixer rules together, fast
  5. Slevomat Coding Standard Extra PHP_CodeSniffer sniffs for safer, cleaner and consistently formatted PHP
  6. PHPMD PHP Mess Detector: finds bugs and code smells in PHP

Compare PHP_CodeSniffer Standards Composer Installer Plugin with the top 3