PHPackages                             tiagohillebrandt/phpcs-diff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. tiagohillebrandt/phpcs-diff

ActiveLibrary[Testing &amp; Quality](/categories/testing)

tiagohillebrandt/phpcs-diff
===========================

Detects coding standard violations based on a git diff.

3.0.1(1y ago)14.0k↓50%[2 issues](https://github.com/tiagohillebrandt/phpcs-diff/issues)MITPHPPHP &gt;=7.3.0

Since Jul 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/tiagohillebrandt/phpcs-diff)[ Packagist](https://packagist.org/packages/tiagohillebrandt/phpcs-diff)[ Docs](https://github.com/tiagohillebrandt/phpcs-diff)[ RSS](/packages/tiagohillebrandt-phpcs-diff/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (4)Used By (0)

phpcs-diff
==========

[](#phpcs-diff)

`phpcs-diff` detects violations of a defined set of coding standards based on a `git diff`.

[![Latest Stable Version](https://camo.githubusercontent.com/4448dd48d93445493e5a1b29e41021ade119e62ce64dc2d321d2a9cdeb1544b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f746961676f68696c6c656272616e64742f70687063732d646966662e7376673f7374796c653d666c6174266c6162656c3d72656c65617365)](https://github.com/tiagohillebrandt/phpcs-diff/tags)[![Minimum PHP Version](https://camo.githubusercontent.com/13b629e6318e92f4bcf9d9f97f1871db63d7372efd418ab1cccd001d195adf06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f746961676f68696c6c656272616e64742f70687063732d646966662f7068702e7376673f63616368655365636f6e64733d33363030)](https://camo.githubusercontent.com/13b629e6318e92f4bcf9d9f97f1871db63d7372efd418ab1cccd001d195adf06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f746961676f68696c6c656272616e64742f70687063732d646966662f7068702e7376673f63616368655365636f6e64733d33363030)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE)[![GitHub Issues](https://camo.githubusercontent.com/0e4202611c9e54ec114582c544acf16e54cb8e1a2adc5975ee5a3bcc28c697ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f746961676f68696c6c656272616e64742f70687063732d646966662e737667)](https://github.com/tiagohillebrandt/phpcs-diff/issues)[![Total Downloads](https://camo.githubusercontent.com/f0bc10244c7aee54af719ded096102652d715ab32278b73c33c24a31ed34aca4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746961676f68696c6c656272616e64742f70687063732d646966662e7376673f7374796c653d666c6174)](https://packagist.org/packages/tiagohillebrandt/phpcs-diff)

Requirements
------------

[](#requirements)

The latest version of `phpcs-diff` requires PHP version 7.3.0 or later.

This project also depends on `squizlabs/php_codesniffer` which is used internally to fetch the failed violations via `phpcs`.

Finally, the `league/climate` package is also installed. This is to deal with console output, but this dependency may be removed in a future release.

Installation
------------

[](#installation)

### Composer

[](#composer)

If you use Composer, you can install `phpcs-diff` system-wide with the following command:

```
composer global require tiagohillebrandt/phpcs-diff
```

It's also possible to install `phpcs-diff` as a development dependency in your project:

```
composer require --dev tiagohillebrandt/phpcs-diff
```

Or alternatively, you can manually include a dependency for `tiagohillebrandt/phpcs-diff` in your `composer.json` file. For example:

```
{
    "require-dev": {
        "tiagohillebrandt/phpcs-diff": "^3.0"
    }
}
```

You will then be able to run phpcs-diff from the vendor bin directory:

```
./vendor/bin/phpcs-diff
```

### Git Clone

[](#git-clone)

You can also download the `phpcs-diff` source and create a symlink to your `/usr/bin` directory:

```
git clone https://github.com/tiagohillebrandt/phpcs-diff.git
cd phpcs-diff
php bin/phpcs-diff main -v
```

You could also add a symlink to your `/usr/bin` directory:

```
ln -s phpcs-diff/bin/phpcs-diff /usr/bin/phpcs-diff
```

Getting Started
---------------

[](#getting-started)

### Basic Usage

[](#basic-usage)

```
phpcs-diff   -v
```

In this example, the current branch is compared to the `main` branch. `phpcs-diff` would execute the following diff statement behind the scenes:

```
git diff current-branch main
```

*Please note:*

- The `-v` flag is optional and provides verbose output during processing.
- The `current-branch` parameter is optional. If not specified, `phpcs-diff` will use the current commit hash obtained via `git rev-parse --verify HEAD`.
- By default, `phpcs-diff` looks for the `ruleset.xml` file in the root directory of the project. To use a different ruleset file or standard, specify it using the `--standard` option.

After running `phpcs-diff`, the executable will return an output similar to the following:

```
########## START OF PHPCS CHECK ##########
module/Poject/src/Console/Script.php
 - Line 28 (WARNING) Line exceeds 120 characters; contains 190 characters
 - Line 317 (ERROR) Blank line found at end of control structure
########### END OF PHPCS CHECK ###########

```

### Custom Standards and Ruleset Files

[](#custom-standards-and-ruleset-files)

`phpcs-diff` allows you to specify custom coding standards and ruleset files to suit your needs. For example, to use a predefined standard like PSR-12, you can run:

```
phpcs-diff --standard=PSR12 main
```

You can find a list of available standards in [PHP\_CodeSniffer's GitHub repository](https://github.com/PHPCSStandards/PHP_CodeSniffer/tree/master/src/Standards).

To apply a custom ruleset file, simply use:

```
phpcs-diff --standard=phpcs.xml.dist main
```

These options let you customize the code analysis to align with your specific coding standards and project requirements.

About
-----

[](#about)

`phpcs-diff` detects violations of a defined set of coding standards based on a `git diff`. It uses `phpcs` from the [PHP\_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) project.

This project offers the following benefits:

- Accelerates your CI/CD pipeline by validating only the modified files instead of the entire codebase.
- Facilitates the migration of legacy codebases, enabling incremental compliance with coding standards without the risk of extensive changes at once.

This executable works by checking the changed lines, compared to the base branch, against all failed violations for those files. This ensures that any new or changed code will be compliant.

Over time, this approach will help your codebase become more compliant with the coding standard, and you may eventually reach a point where you can run `phpcs` on the entire codebase.

### Fork

[](#fork)

This project is derived from the **olivertappin/phpcs-diff** library. It was created to ensure more frequent updates, as the original repository appears to be abandoned.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~298 days

Total

2

Last Release

371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4158eb724a262e112aef1614bdd118b9f240f1dab3508a6566ba393dc8221a97?d=identicon)[tiagohillebrandt](/maintainers/tiagohillebrandt)

---

Top Contributors

[![tiagohillebrandt](https://avatars.githubusercontent.com/u/1733911?v=4)](https://github.com/tiagohillebrandt "tiagohillebrandt (29 commits)")[![olivertappin](https://avatars.githubusercontent.com/u/9773040?v=4)](https://github.com/olivertappin "olivertappin (19 commits)")[![TotalWipeOut](https://avatars.githubusercontent.com/u/1478524?v=4)](https://github.com/TotalWipeOut "TotalWipeOut (7 commits)")[![zen1t](https://avatars.githubusercontent.com/u/9872888?v=4)](https://github.com/zen1t "zen1t (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tiagohillebrandt-phpcs-diff/health.svg)

```
[![Health](https://phpackages.com/badges/tiagohillebrandt-phpcs-diff/health.svg)](https://phpackages.com/packages/tiagohillebrandt-phpcs-diff)
```

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[magento/magento-coding-standard

A set of Magento specific PHP CodeSniffer rules.

37113.4M299](/packages/magento-magento-coding-standard)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13176.9k8](/packages/youwe-testing-suite)[olivertappin/phpcs-diff

Detects violations of a defined coding standard based on a git diff.

12147.6k](/packages/olivertappin-phpcs-diff)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
