whatisgithub

What is php_codesniffer?

squizlabs/php_codesniffer — explained in plain English

Analysis updated 2026-06-24

10,773PHPAudience · developerComplexity · 2/5Setup · easy

In one sentence

A command-line tool that checks PHP, JavaScript, and CSS files against coding style rules and can automatically fix many violations, note this repo is abandoned, active development is at PHPCSStandards/PHP_CodeSniffer.

Mindmap

mindmap
  root((PHP CodeSniffer))
    What it does
      Style checking
      Auto-fix with phpcbf
      Multi-language
    Standards
      PSR-12
      PEAR
      Custom rules
    Use cases
      Pre-commit checks
      CI pipelines
      Team consistency
    Audience
      PHP developers
    Status
      Abandoned repo
      Successor exists
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run style checks on PHP files before committing to catch formatting violations like wrong indentation or naming conventions.

USE CASE 2

Automatically fix common coding standard violations in a PHP codebase using the companion phpcbf command.

USE CASE 3

Add automated style enforcement to a CI pipeline so every pull request is checked against PSR-12 or a custom standard before merging.

What is it built with?

PHPComposer

How does it compare?

squizlabs/php_codesniffertennc/webshellmockery/mockery
Stars10,77310,72710,724
LanguagePHPPHPPHP
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

This repository is abandoned, use PHPCSStandards/PHP_CodeSniffer for active development and security fixes.

So what is it?

PHP_CodeSniffer is a command-line tool for checking PHP, JavaScript, and CSS files against a defined set of coding style rules. It tells you when your code breaks those rules, and a companion tool called phpcbf can automatically fix many of the violations it finds. The goal is to keep a codebase consistent when multiple people are working on it, or when a project has agreed to follow a particular formatting standard. Note that this specific repository has been officially abandoned by its original maintainers. Active development moved to a successor repository at PHPCSStandards/PHP_CodeSniffer, which is where new releases, bug fixes, and contributions now go. The tool works by reading your source files and applying a set of rules called a coding standard. It ships with several built-in standards, including PEAR and PSR-12, which are widely used naming and formatting conventions in the PHP world. You can also write your own custom rules. You run it from the command line pointing it at a file or directory, and it produces a report showing which lines have violations and what the problem is. Installation can be done through Composer (the standard PHP package manager), via Phive, via the older PEAR installer, or by downloading standalone executable files called Phars that do not need any package manager. The tool requires PHP version 5.4 or higher. It is most useful as part of an automated quality check, such as running it on every code commit in a continuous integration pipeline to catch style problems before they are merged. The README notes that some individual rules may have additional requirements beyond PHP itself. The project uses a standard MAJOR.MINOR.PATCH version numbering scheme.

Copy-paste prompts

Prompt 1
I have a PHP project and want to enforce PSR-12 coding standards using PHP_CodeSniffer. Show me how to install it via Composer and run it against a src/ directory.
Prompt 2
Using phpcbf, automatically fix PSR-12 violations in my PHP files. Show the command and what kinds of issues it can and cannot fix.
Prompt 3
How do I add PHP_CodeSniffer to a GitHub Actions CI workflow so it checks every pull request? Show the workflow YAML.
Prompt 4
How do I create a custom PHP_CodeSniffer ruleset XML file that extends PSR-12 but excludes a specific rule? Show an example phpcs.xml.

Frequently asked questions

What is php_codesniffer?

A command-line tool that checks PHP, JavaScript, and CSS files against coding style rules and can automatically fix many violations, note this repo is abandoned, active development is at PHPCSStandards/PHP_CodeSniffer.

What language is php_codesniffer written in?

Mainly PHP. The stack also includes PHP, Composer.

How hard is php_codesniffer to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is php_codesniffer for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.