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

Symfony2 Coding Standard Laravel Package

escapestudios/symfony2-coding-standard

PHP_CodeSniffer ruleset applying Symfony2 coding standards. Helps enforce consistent formatting, naming, and best practices in Symfony/PHP projects. Easy to install via Composer and integrate into CI to catch style issues early.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install via Composer: Run composer require --dev escapestudios/symfony2-coding-standard in your Symfony project.
  2. Configure PHPCS: Add to phpcs.xml (or create one in project root):
    <?xml version="1.0"?>
    <ruleset name="Symfony">
      <rule ref="vendor/escapestudios/symfony2-coding-standard/Symfony"/>
      <file>src/</file>
      <file>tests/</file>
    </ruleset>
    
  3. First check: Run vendor/bin/phpcs to scan code for violations.
  4. Auto-fix: Use vendor/bin/phpcbf to automatically fix PSR and Symfony-specific sniffs (e.g., method visibility, type declarations, PHPDoc ordering).

Implementation Patterns

  • IDE Integration: Configure PHP_CodeSniffer in PhpStorm/VS Code (phpcs extension) to show live warnings.
  • CI Enforcement: Include phpcs in GitHub Actions/GitLab CI:
    - run: vendor/bin/phpcs -n
    
  • Pre-commit Hook: Use husky + lint-staged to run phpcbf only on staged files for incremental compliance.
  • Extension: Extend the standard by adding custom sniffs (e.g., Doctrine-specific rules) via phpcs.xml ruleset inheritance.
  • Gradual Adoption: Start with phpcs --standard=PSR12 then layer in Symfony standard per-file to avoid breaking legacy code.

Gotchas and Tips

  • PHPCS Version Mismatch: Requires PHPCS ≥3.3. Older versions (e.g., PHPCS 2.x) fail to parse some rules—upgrade via composer global require "squizlabs/php_codesniffer=*" if needed.
  • Blank Lines in Method Chaining: The standard enforces strict line breaks in method chains (e.g., after ->), which may conflict with developer style. Override via <exclude name="Symfony.Functions.MultiLineFunctionBrace"/> in phpcs.xml.
  • PHP 8+ Conflicts: Symfony.Functions.MultiLineFunctionBrace may conflict with native type hints—ensure phpstan/phpstan is used for deeper static analysis.
  • False Positives in Twig: Avoid phpcs on .twig files—use symfony/twig-pack’s built-in linting instead.
  • Debugging Sniffs: Run phpcs -v for verbose output or phpcs -i to list installed standards.
  • Override Sniffs: Disable overly strict rules globally:
    <rule ref="Symfony.NamingConventions.ValidVariableName.PrivateVarName">
      <type>error</type>
    </rule>
    <rule ref="Symfony.NamingConventions.ValidVariableName.PrivateVarName">
      <severity>0</severity>
    </rule>
    
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