Weave Code
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
Coding Standard

Coding Standard Laravel Package

lcobucci/coding-standard

PHPCS coding standard based on Doctrine’s rules with a few tweaks. Provides a reusable ruleset to enforce consistent PHP code style across projects, suitable for CI checks and team-wide formatting conventions.

View on GitHub
Deep Wiki
Context7

A modified version version of doctrine/coding-standard which I like to use for my projects

Frequently asked questions about Coding Standard
How do I install lcobucci/coding-standard in a Laravel project?
Run `composer require --dev lcobucci/coding-standard` to install the package. It requires PHP_CodeSniffer (PHPCS) 4.0+, which you can install via `composer require --dev squizlabs/php_codesniffer`. Configure it in your `phpcs.xml` or `.php-cs-fixer.dist.php` to override default rules.
Does this package work with Laravel’s default PSR-12 standard?
Yes, it’s designed to complement or replace PSR-12. The ruleset includes Doctrine-inspired refinements (e.g., stricter docblocks, attribute formatting) while avoiding conflicts. Audit for overlaps using `phpcs --report=full` before enforcing.
What Laravel and PHP versions does lcobucci/coding-standard support?
The package requires PHP 8.4+ (since v12.0.0) and works with Laravel 10/11. For older versions (e.g., Laravel 9/PHP 8.1), upgrade PHP incrementally or use `--ignore-errors` during transition. Check compatibility with your Laravel version’s PHPCS setup.
Can I integrate this into Laravel’s CI/CD pipeline?
Absolutely. Use GitHub Actions with `squizlabs/php_codesniffer` or GitLab CI’s PHPCS Docker images. Add a step to run `phpcs` with your configured ruleset, blocking merges for violations if desired. Cache results to optimize CI performance.
How does this differ from php-cs-fixer for Laravel?
While `php-cs-fixer` automates fixes, this package enforces stricter static analysis rules (e.g., docblocks, attributes) via PHPCS. Use both together: `php-cs-fixer` for auto-fixes and this ruleset for enforcement in CI. It’s complementary, not a replacement.
Will this break existing Laravel projects with custom coding standards?
Minimal risk if you audit conflicts first. Start with `--ignore-errors` to identify violations, then phase in fixes. For deep customizations, fork the package (MIT license) or extend PHPCS rulesets. Most Laravel projects using PSR-12 will adapt smoothly.
How do I handle legacy codebases (e.g., PHP 7.4) with this package?
Upgrade PHP incrementally or exclude legacy directories in `phpcs.xml` using `<exclude-patterns>`. For critical legacy code, enforce rules locally with `--ignore-errors` while planning a migration. Pair with `php-cs-fixer` to automate fixes for newer code.
Can I customize or extend the rules beyond Doctrine’s defaults?
Yes, the MIT license allows forking. For minor tweaks, override rules in `phpcs.xml`. For significant changes, maintain a custom PHPCS ruleset. The package’s simplicity makes it easy to adapt without heavy maintenance overhead.
How does this improve Laravel’s developer experience (DX)?
By enforcing consistent style and catching issues early (e.g., docblock errors, attribute formatting), it reduces merge conflicts and onboarding friction. Integrate it as a pre-commit hook or CI gate to catch violations before they reach production.
Are there alternatives to lcobucci/coding-standard for Laravel?
Yes, consider `php-cs-fixer` for auto-fixes, `dealerdirect/phpcodesniffer-composer-installer` for PHPCS setup, or `symfony/shift/coding-standard` for Symfony-aligned rules. This package stands out for its Doctrine-inspired balance of strictness and Laravel compatibility.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata