PHPackages                             yiisoft/yii2-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. [Framework](/categories/framework)
4. /
5. yiisoft/yii2-coding-standards

ActivePhpcodesniffer-standard[Framework](/categories/framework)

yiisoft/yii2-coding-standards
=============================

Yii PHP Framework Version 2 - Coding standard tools

3.0.1(1y ago)1831.0M↓18.8%49[1 issues](https://github.com/yiisoft/yii2-coding-standards/issues)20BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jul 11Pushed 2mo ago37 watchersCompare

[ Source](https://github.com/yiisoft/yii2-coding-standards)[ Packagist](https://packagist.org/packages/yiisoft/yii2-coding-standards)[ Docs](https://www.yiiframework.com/)[ Fund](https://opencollective.com/yiisoft)[ RSS](/packages/yiisoft-yii2-coding-standards/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (20)

Yii 2 Web Framework Coding Standard
===================================

[](#yii-2-web-framework-coding-standard)

This repository contains settings for [Yii2 coding style](https://github.com/yiisoft/yii2/wiki/Core-framework-code-style)for various tools.

Getting code
------------

[](#getting-code)

You can get code style definition using one of the following methods.

- Clone `yiisoft/yii2-coding-standards` repository:

```
git clone git@github.com:yiisoft/yii2-coding-standards.git
```

- Install `composer.phar` distribution:

```
curl -sS https://getcomposer.org/installer | php
```

Or if your system doesn't have CURL installed:

```
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
```

- Set up all dependencies declared in `composer.json`:

```
php composer.phar install
```

PHP\_Codesniffer
----------------

[](#php_codesniffer)

[PHP\_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) coding standard, rule set and sniff token parsing classes for the [Yii 2 Web Framework](https://github.com/yiisoft/yii2/). Overally rules are based on PSR-12 standard with some minor exceptions and changes. Rules derived from PSR-12 standard and excluded in Yii2 standard were implemented (or planned to be) as sniff classes.

Rules could also be used for checking code style of an existing Yii2 applications.

Everything that is merged into main [Yii2 development repository](https://github.com/yiisoft/yii2) being checked with these rule set as well.

### Using code style

[](#using-code-style)

After CodeSniffer is installed you can launch it with custom code style using the following syntax:

```
$ ./vendor/bin/phpcs --extensions=php --standard=Yii2 /home/resurtm/work/Yii2MegaApp/

```

Installation can be also be done automatically with this tool:

```
composer require --dev dealerdirect/phpcodesniffer-composer-installer
```

When using Composer 2.2 or higher, Composer will [ask for your permission](https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution) to allow this plugin to execute code. For this plugin to be functional, permission needs to be granted.

When permission has been granted, the following snippet will automatically be added to your `composer.json` file by Composer:

```
{
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true
        }
    }
}
```

When using Composer &lt; 2.2, you can add the permission flag ahead of the upgrade to Composer 2.2, by running:

```
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
```

If you're using PhpStorm you can configure it to use CodeSniffer using Settings → PHP → Code Sniffer. Yii2 code style can be specified at Inspections → PHP → PHP Code Sniffer validation.

### Useful links

[](#useful-links)

- [Configuration options](https://pear.php.net/manual/en/package.php.php-codesniffer.config-options.php)
- [Manual and guide](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki)
- [GitHub repository](https://github.com/PHPCSStandards/PHP_CodeSniffer)

PhpStorm
--------

[](#phpstorm)

Yii uses PSR-12 as code style standard. You can choose these via `Settings` → `Code Style` → `PHP` → `Set from...` → `Predefined Style` → `PSR12`.

ADDITIONAL NOTES
----------------

[](#additional-notes)

Feel free to request additional features, submit bugs and problems.

Thank you for choosing Yii Framework!

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance63

Regular maintenance activity

Popularity58

Moderate usage in the ecosystem

Community50

Growing community involvement

Maturity63

Established project with proven stability

 Bus Factor4

4 contributors hold 50%+ of commits

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 ~517 days

Recently: every ~693 days

Total

8

Last Release

706d ago

Major Versions

2.0.4 → 3.0.02024-03-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/261a6249c6f605f3956a2fae40fbb813f6b2e1e6f2bf806180c851a965426e54?d=identicon)[cebe](/maintainers/cebe)

![](https://www.gravatar.com/avatar/fc29e4e7068a00fe9b9db37b8aadda1db6020adcacef810461e47b99c2b150e6?d=identicon)[samdark](/maintainers/samdark)

![](https://www.gravatar.com/avatar/23416c58e0dce33a8369451a4ca0e28666373594027debc10184b37ade6a926b?d=identicon)[qiangxue](/maintainers/qiangxue)

![](https://www.gravatar.com/avatar/ccb75e3312d6bd454ea445ea308139fd185a4ca906ca5df21cc66e6a35de25a3?d=identicon)[SilverFire](/maintainers/SilverFire)

---

Top Contributors

[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (11 commits)")[![resurtm](https://avatars.githubusercontent.com/u/100198?v=4)](https://github.com/resurtm "resurtm (4 commits)")[![nkovacs](https://avatars.githubusercontent.com/u/2269242?v=4)](https://github.com/nkovacs "nkovacs (4 commits)")[![edgardmessias](https://avatars.githubusercontent.com/u/1530997?v=4)](https://github.com/edgardmessias "edgardmessias (4 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (3 commits)")[![AlexGx](https://avatars.githubusercontent.com/u/1571119?v=4)](https://github.com/AlexGx "AlexGx (2 commits)")[![Arhell](https://avatars.githubusercontent.com/u/26163841?v=4)](https://github.com/Arhell "Arhell (2 commits)")[![bizley](https://avatars.githubusercontent.com/u/8577314?v=4)](https://github.com/bizley "bizley (2 commits)")[![razvanphp](https://avatars.githubusercontent.com/u/4599319?v=4)](https://github.com/razvanphp "razvanphp (2 commits)")[![krukru](https://avatars.githubusercontent.com/u/10072630?v=4)](https://github.com/krukru "krukru (1 commits)")[![qiangxue](https://avatars.githubusercontent.com/u/993322?v=4)](https://github.com/qiangxue "qiangxue (1 commits)")[![WinterSilence](https://avatars.githubusercontent.com/u/3521094?v=4)](https://github.com/WinterSilence "WinterSilence (1 commits)")[![gsherwood](https://avatars.githubusercontent.com/u/185976?v=4)](https://github.com/gsherwood "gsherwood (1 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (1 commits)")[![frenck](https://avatars.githubusercontent.com/u/195327?v=4)](https://github.com/frenck "frenck (1 commits)")[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (1 commits)")[![tanakahisateru](https://avatars.githubusercontent.com/u/403893?v=4)](https://github.com/tanakahisateru "tanakahisateru (1 commits)")[![terabytesoftw](https://avatars.githubusercontent.com/u/42547589?v=4)](https://github.com/terabytesoftw "terabytesoftw (1 commits)")[![marinazzio](https://avatars.githubusercontent.com/u/11504185?v=4)](https://github.com/marinazzio "marinazzio (1 commits)")

---

Tags

codesniffercoding-standardshacktoberfestyii2frameworkcodesnifferyii

### Embed Badge

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

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

###  Alternatives

[cakephp/cakephp-codesniffer

CakePHP CodeSniffer Standards

23711.0M658](/packages/cakephp-cakephp-codesniffer)[spryker/code-sniffer

Spryker Code Sniffer Standards

374.1M2.3k](/packages/spryker-code-sniffer)[hprose/hprose-yii

Hprose Server for Yii 2

357.1k](/packages/hprose-hprose-yii)[linnk/allman-codesniffer

Allman CodeSniffer &amp; Linnk Standards

121.8k](/packages/linnk-allman-codesniffer)[yiisoft/cache-apcu

Yii Caching Library - APCu Handler

136.5k](/packages/yiisoft-cache-apcu)

PHPackages © 2026

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