Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yii2 Coding Standards Laravel Package

yiisoft/yii2-coding-standards

The PHP_CodeSniffer coding standard used by Yii2 core and official extensions. Based on PSR-12 with documented Yii-specific exceptions, it lets you check and automatically fix PHP code with phpcs and phpcbf via the Yii2 ruleset. Requires PHP 7.4+ and PHP_CodeSniffer 4.0.2+.

View on GitHub
Deep Wiki
Context7

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.

Latest Stable Version Total Downloads

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:

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:

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:

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

Automatically fix supported violations with PHP Code Beautifier and Fixer:

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

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

./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 version="1.0"?>
<ruleset name="Project">
    <rule ref="Yii2"/>

    <file>src</file>
    <file>tests</file>
</ruleset>

Then run PHP_CodeSniffer without additional arguments:

./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

Support the project

Open Collective

Follow updates

Official website Follow on X Telegram Slack

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc