wyrihaximus/coding-standard
PHP coding standard package for consistent formatting and style in PHP projects. Provides ready-to-use rulesets and configuration to streamline linting, code style checks, and enforcement across teams and CI pipelines.
This package is a preconfigured PHP Coding Standard built on top of PHP_CodeSniffer (PHPCS), Slevomat Coding Standard, and Doctrine Coding Standard. To start using it:
composer require --dev wyrihaximus/coding-standard
phpcs.xml.dist) that extends the standard:
<?xml version="1.0"?>
<ruleset name="MyProjectStandard">
<file>src</file>
<file>tests</file>
<rule ref="WyriHaximus"/>
</ruleset>
./vendor/bin/phpcs
Or install automatically with PHPCSFixer/PHPCBF (optional, but common workflow):
./vendor/bin/phpcbf
The default configuration targets PHP 8.4+, and leverages modern coding standards (Slevomat + Doctrine) with a focus on consistency, static analysis safety, and PHP’s latest features.
<rule ref="WyriHaximus"/> and override only what you need (e.g., specific sniff settings inside <rule>)phpcs.yml):
- name: Run PHPCS
run: vendor/bin/phpcs -n
vendor/bin/phpcs and phpcs.xml.dist as the config.phpcbf — add scripts to composer.json:
{
"scripts": {
"lint": "phpcs",
"lint:fix": "phpcbf"
}
}
phpcs.xml.dist at root, and reference subdirectories via <file> elements; avoid per-package duplication.php CLI matches your target.phpcs.xml; you must define your own. Start from vendor/wyrihaximus/coding-standard/phpcs.xml.dist (if present) or build from scratch — but do not copy it verbatim as it’s subject to change.SlevomatCodingStandard.TypeHints.ReturnTypeHint vs Doctrine\ORM\Sniffs\Annotations\ReturnTypeHintSniff). Use <exclude> tags to resolve duplicates:
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
</rule>
<severity>, <exclude>, and <properties> in your phpcs.xml — the base ruleset is opinionated and strict (e.g., forbids @api, enforces declare(strict_types=1)).targetVersion isn’t set correctly — explicitly set <arg name="basepath" value="."/> and <arg name="encoding" value="utf-8"/> if issues arise.How can I help you explore Laravel packages today?