Did you find something wrong? Be sure to let us know with an issue. Thank you!
Coding Standard
Webisters Coding Standard is the shared PHP-CS-Fixer rule set used across every Webisters library and project. Drop it in once and your codebase formats consistently with the rest of the ecosystem.
- Installation
- Configure your project
- Running the fixer
- What it enforces
- Editor integration
- Conclusion
Installation
composer require --dev webisters/coding-standard
This pulls in friendsofphp/php-cs-fixer as a transitive dependency.
Configure your project
Create a .php-cs-fixer.dist.php at the root of your project and use the helpers provided by this library:
<?php
use Framework\CodingStandard\Config;
use Framework\CodingStandard\Finder;
return Config::create()
->setFinder(Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests']));
Config::create() returns a pre-configured PhpCsFixer\Config with the Webisters rule set already applied. Finder::create() returns a PhpCsFixer\Finder with sensible exclusions for vendor, build, and similar directories.
Running the fixer
Format your code in place:
vendor/bin/php-cs-fixer fix
Or dry-run to see what would change without writing files:
vendor/bin/php-cs-fixer fix --dry-run --diff
Use the dry-run in CI to fail the build when style drifts.
What it enforces
The rule set is built on top of the PSR-12 base with stricter additions:
- Declare strict types and namespace ordering on every file.
- Short array syntax, trailing commas in multi-line arrays.
- Single-quoted strings unless interpolation is needed.
- Ordered imports, no unused imports, no leading slash on use statements.
- PHPDoc alignment and removal of redundant tags.
- Modern PHP 8 features encouraged (named arguments, constructor promotion, match).
Editor integration
PhpStorm, VS Code (via the PHP CS Fixer extension), and Vim all support running the fixer on save. Point them at your project's .php-cs-fixer.dist.php and they'll pick up the Webisters rule set automatically.
Conclusion
Consistent style is one less thing to argue about in code review. Adding this library to your dev dependencies is a one-time cost that pays back forever.