talira

laminas-coding-standard

The Laminas Project's PHP_CodeSniffer coding standard ruleset, built on PSR-12

open sourceBSD-3-Clausefree

laminas-coding-standard is the coding standard ruleset the Laminas Project uses for its components, packaged for PHP_CodeSniffer. It extends and expands PSR-12 and requires PSR-1, adding rules for the things those minimal specifications leave open, such as whitespace around operators, aligning array keys and object operations, formatting multi-line conditionals and which functions to import, so code stays consistent within and between components. You install it as a Composer dev dependency and point a phpcs.xml at it, then check with phpcs and fix with phpcbf.

Problems it solves

  • enforce a consistent PHP coding style beyond PSR-12
  • use the same coding standard as the Laminas components
  • stop code review arguments about spacing and alignment in PHP

Features

  • a PHP_CodeSniffer ruleset extending PSR-12 and requiring PSR-1
  • rules for operator whitespace, array and object alignment and multi-line conditionals
  • rules for what to import and how
  • fix violations automatically with phpcbf

Alternatives

The same job

These do what laminas-coding-standard does.

  1. PHP_CodeSniffer Detect and fix coding standard violations in PHP
  2. Slevomat Coding Standard Extra PHP_CodeSniffer sniffs for safer, cleaner and consistently formatted PHP
  3. Easy Coding Standard (ECS) Runs PHP_CodeSniffer and PHP-CS-Fixer rules together, fast
  4. WordPress Coding Standards for PHP_CodeSniffer PHP_CodeSniffer rules that enforce WordPress coding conventions
  5. Credo Static code analysis for Elixir, with a focus on teaching and code consistency

Compare laminas-coding-standard with the top 3