PHPackages                             wearerequired/coding-standards - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. wearerequired/coding-standards

ActivePhpcodesniffer-standard[Validation &amp; Sanitization](/categories/validation)

wearerequired/coding-standards
==============================

required Coding Standards

6.0.0(2y ago)1239.9k↑42.9%2[5 PRs](https://github.com/wearerequired/coding-standards/pulls)9GPL-2.0-or-laterJavaScriptPHP ^7.2 || ^8.0

Since Mar 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wearerequired/coding-standards)[ Packagist](https://packagist.org/packages/wearerequired/coding-standards)[ RSS](/packages/wearerequired-coding-standards/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (39)Used By (9)

required Coding Standards
=========================

[](#required-coding-standards)

[![eslint-config version](https://camo.githubusercontent.com/d15bc627df26410f76353dacf66c7229e259df459861ea3df8eac1c2d371f206/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f40776561726572657175697265642f65736c696e742d636f6e6669673f6c6162656c3d65736c696e742d636f6e666967)](https://www.npmjs.com/package/@wearerequired/eslint-config) [![phpcodesniffer version](https://camo.githubusercontent.com/885256810d5d3a20a9b88f556d5542a905a3526ce28b511e80e9d1e64f266c97/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776561726572657175697265642f636f64696e672d7374616e64617264733f6c6162656c3d706870636f6465736e69666665722d7374616e64617264)](https://packagist.org/packages/wearerequired/coding-standards) [![stylelint-config version](https://camo.githubusercontent.com/be97247cc9e4d36ba82322586f2747b74008a81d23387071c259b20870d11360/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f40776561726572657175697265642f7374796c656c696e742d636f6e6669673f6c6162656c3d7374796c656c696e742d636f6e666967)](https://www.npmjs.com/package/@wearerequired/stylelint-config)

The required coding standards represent the best practices for enabling a consistent code style across the team. The standards do not only contain stylistic rules. They are also defined to prevent potential security vulnerabilities or to leverage more modern syntax for enhanced performance.
This project is inspired by the [Human Made Coding Standards](https://github.com/humanmade/coding-standards) project.

For the JavaScript coding standard head over to [@wearerequired/eslint-config](packages/eslint-config).
For the (S)CSS coding standard head over to [@wearerequired/stylelint-config](packages/stylelint-config).

For team members: Please contact our internal handbook if you need help with [setting up the coding standards in your environment](https://handbook.required.com/development/coding-standards/).

required PHP Coding Standard
----------------------------

[](#required-php-coding-standard)

### Setup

[](#setup)

1. `composer require --dev dealerdirect/phpcodesniffer-composer-installer wearerequired/coding-standards`
2. Run the standards checks using the following command:

```
vendor/bin/phpcs .

```

The final `.` here specifies the files you want to test; this is typically the current directory (`.`), but you can also selectively check files or directories by specifying them instead.

You can add this to your Travis CI configuration as a test:

```
script:
  - phpunit
  - vendor/bin/phpcs .
```

**Bonus**: To make things easier, you can add something as follows to your `composer.json` file:

```
{
	"scripts": {
		"format": "vendor/bin/phpcbf --report-summary --report-source .",
		"lint": "vendor/bin/phpcs --report-summary --report-source ."
	}
}
```

After that, run `composer lint` to run the standards checks and `composer format` to try auto-fixing of errors and warnings.

#### Excluding Files

[](#excluding-files)

This standard includes special support for a `.phpcsignore` file (in the future, this should be [built into phpcs itself](https://github.com/squizlabs/PHP_CodeSniffer/issues/1884)). You can place a `.phpcsignore` file in your root directory (wherever you're going to run `phpcs` from).

The format of this file is similar to `.gitignore` and similar files: one pattern per line, comment lines should start with a `#`, and whitespace-only lines are ignored:

```
# Exclude our tests directory.
tests/

# Exclude any file ending with ".inc"
*\.inc

```

Note that the patterns should match [the PHP\_CodeSniffer style](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders): `*` is translated to `.*` for convenience, but all other characters work like a regular expression.

Patterns are relative to the directory that the `.phpcsignore` file lives in. On load, they are translated to absolute patterns: e.g. `*/tests/*` in `/your/dir/.phpcsignore` will become `/your/dir/.*/tests/.*` as a regular expression. **This differs from the regular PHP\_CodeSniffer practice.**

#### Advanced/Extending

[](#advancedextending)

You can create your own custom standard file (e.g. `phpcs.xml.dist`) if you want to extend these coding standards:

```

	Project specific coding standard.

	.

```

You can then reference this file when running phpcs:

```
vendor/bin/phpcs

```

An example for a custom rule is to validate the text domain:

```

```

or to ensure the correct prefix is used:

```

```

If the project is a WordPress theme you have to set the following rule:

```

```

### Included Checks

[](#included-checks)

The phpcs standard is based upon the `WordPress-Core`, `WordPress-Docs`, and `WordPress-Extra` rules from the [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards). It also uses [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis) for problematic variable use and some `SlevomatCodingStandard` rules from the [Slevomat Coding Standard](https://github.com/slevomat/coding-standard). Most of the sniffs are also providing automatic errors fixing for `phpcbf`.

EditorConfig
------------

[](#editorconfig)

The [EditorConfig](https://editorconfig.org/) standard helps developers define and maintain consistent coding styles between different editors and IDEs. This way it's easier to follow the given coding standards in a project, without the need to fiddle with IDE settings.

The recommended `.editorconfig` file for a WordPress project looks like this:

```
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[{*.json,*.yml}]
indent_style = space
indent_size = 2
```

[![a required open source product - let's get in touch](https://camo.githubusercontent.com/47e05f68aa9692e2185b9c29cb810dcd02ea3546c00fb25e0152a343154b76bf/68747470733a2f2f6d656469612e72657175697265642e636f6d2f696d616765732f6f70656e2d736f757263652d62616e6e65722e706e67)](https://required.com/en/lets-get-in-touch/)

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 53.4% 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 ~54 days

Recently: every ~94 days

Total

34

Last Release

830d ago

Major Versions

1.6.0 → 2.0.0-beta.02020-12-15

2.2.0 → 3.0.0-alpha.02022-02-07

3.0.0 → 4.0.0-beta.02022-12-08

4.0.0 → 5.0.02023-01-27

5.0.0 → 6.0.0-alpha.02024-02-03

PHP version history (3 changes)1.1.0PHP ^7.1

3.0.0-alpha.0PHP ^7.1 || ^8.0

4.0.0-beta.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1446895?v=4)[required](/maintainers/wearerequired)[@wearerequired](https://github.com/wearerequired)

---

Top Contributors

[![ocean90](https://avatars.githubusercontent.com/u/617637?v=4)](https://github.com/ocean90 "ocean90 (156 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (69 commits)")[![swissspidy](https://avatars.githubusercontent.com/u/841956?v=4)](https://github.com/swissspidy "swissspidy (38 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (21 commits)")[![grappler](https://avatars.githubusercontent.com/u/1785641?v=4)](https://github.com/grappler "grappler (7 commits)")[![derpaschi](https://avatars.githubusercontent.com/u/1146235?v=4)](https://github.com/derpaschi "derpaschi (1 commits)")

---

Tags

phpcswordpresswpcs

### Embed Badge

![Health badge](/badges/wearerequired-coding-standards/health.svg)

```
[![Health](https://phpackages.com/badges/wearerequired-coding-standards/health.svg)](https://phpackages.com/packages/wearerequired-coding-standards)
```

###  Alternatives

[drupal/coder

Coder is a library to review Drupal code.

3043.6M461](/packages/drupal-coder)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[infinum/eightshift-coding-standards

Eightshift WordPress Coding Standards

1785.2k3](/packages/infinum-eightshift-coding-standards)[ninjify/coding-standard

Tuned &amp; very strict coding standards for PHP projects. Trusted by Contributte, Apitte, Nettrine and many others.

13497.1k13](/packages/ninjify-coding-standard)[leroy-merlin-br/coding-standard

The coding standard for PHP projects on LMBR

2137.0k10](/packages/leroy-merlin-br-coding-standard)

PHPackages © 2026

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