百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
Y

yii2-coding-standards

> 编程语言
开源

Yii 2 编码标准

182 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Yii 2 编码标准

Coding Standard for Yii 2

This package provides the PHP_CodeSniffer coding standard used by Yii2 core and official extensions. The ruleset is based on PSR-12 with the Yii-specific exceptions documented in the Yii2 core code style. Installation

[!IMPORTANT]

  • The minimum required PHP version is PHP 7.4.
  • The minimum supported PHP_CodeSniffer version is 4.0.2.

The preferred way to install this package is through Composer:

bash
composer require --dev --prefer-dist yiisoft/yii2-coding-standards

To register the Yii2 ruleset automatically, allow and install the PHP_CodeSniffer Standards Composer Installer Plugin:

bash
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev dealerdirect/phpcodesniffer-composer-installer:^1.0

Usage

Check a project with the Yii2 coding standard:

bash
./vendor/bin/phpcs --extensions=php --standard=Yii2 path/to/project

Automatically fix supported violations with PHP Code Beautifier and Fixer:

bash
./vendor/bin/phpcbf --extensions=php --standard=Yii2 path/to/project

Without the Composer installer plugin, reference the ruleset by its installed path:

bash
./vendor/bin/phpcs --extensions=php --standard=vendor/yiisoft/yii2-coding-standards/Yii2 path/to/project

You can also extend the standard from a project-level phpcs.xml or phpcs.xml.dist file:

xml

    

    src
    tests

Then run PHP_CodeSniffer without additional arguments:

bash
./vendor/bin/phpcs

PhpStorm

Configure PHP_CodeSniffer under Settings → PHP → Quality Tools → PHP_CodeSniffer. Enable the inspection under Settings → Editor → Inspections → PHP → Quality tools → PHP_CodeSniffer validation, and select the Yii2 coding standard.

Documentation

  • Yii2 core code style
  • PHP_CodeSniffer documentation
  • PHP_CodeSniffer configuration options

Support the project

Follow updates

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPcodesniffercoding-standardshacktoberfestyii2

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言