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 Laravel Package

ramsey/coding-standard

ramsey/coding-standard provides Ramsey’s PHP_CodeSniffer ruleset to enforce consistent, modern PHP style across projects. Easy to install, integrates with CI, and helps catch formatting and code quality issues early with sensible defaults.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require --dev ramsey/coding-standard. Run PHPCS directly with vendor/bin/phpcs — it auto-detects the included ruleset.xml and applies the ruleset to your project’s source files. For quick validation in a project root, run vendor/bin/phpcs src/. First-time users should run vendor/bin/phpcs --standard=vendor/ramsey/coding-standard/src/Ramsey explicitly to verify setup, or simply rely on auto-detection if placed in root (standard practice). The most immediate value is catching inconsistent spacing, missing type hints, or non-strict comparisons.

Implementation Patterns

  • CI Integration: Add a phpcs step in your workflow (e.g., GitHub Actions, GitLab CI) using vendor/bin/phpcs --standard=vendor/ramsey/coding-standard/src/Ramsey --error-severity=5 --warning-severity=5 src/ tests/. Fail builds on violations.
  • Pre-commit Hook: Use Husky or manual git hooks to run phpcs --fix on staged files, automating formatting before commits.
  • IDE Integration: Configure PhpStorm or VS Code PHP Sniffer extension to use the ramsey/coding-standard ruleset for live feedback.
  • Gradual Adoption: For legacy codebases, run phpcs with --ignore-annotations and --extensions=php only, or exclude large sections via phpcs.xml while enabling strict checks incrementally.
  • Override Selectively: Create a custom phpcs.xml to extend or narrow rules (e.g., disable Squiz.WhiteSpace.ScopeKeywordSpacing if your team prefers it relaxed).

Gotchas and Tips

  • PHPCS Version Compatibility: Requires PHPCS ≥3.7; ensure your composer.json pins squizlabs/php_codesniffer explicitly if conflicting dev dependencies exist.
  • False Positives on Traits/Interfaces: Some sniffs (e.g., naming conventions for traits) may flag edge cases — always verify using --report-diff before auto-fixing.
  • --standard Path Matters: If installing as a dependency (not root), don’t assume --standard=ramsey works; use full path (vendor/ramsey/coding-standard/src/Ramsey) or define custom phpcs.xml.
  • Auto-fix Caution: phpcbf may reorder use statements or alter spacing in strings/comments — review diffs. Prefer phpcs --fix over phpcbf for granular control.
  • Extension Points: Extend ruleset.xml to add custom sniffs (e.g., PHPCompatibility) — the included file is intentionally minimal but modular.
  • Silent Failures: PHPCS exits 0 even on warnings if --warning-severity=0 is used; always test locally with --error-severity=1 --warning-severity=1 during adoption.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport