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

m6web/symfony2-coding-standard

Symfony2 coding standard ruleset for PHP_CodeSniffer from M6Web, providing a ready-to-use standard aligned with Symfony2 conventions to help keep code style consistent across teams and projects.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Avoid Immediate Use: Since this package is deprecated and archived, the first step is to not use it in new projects. It was designed for Symfony2 coding standards but is outdated (last release in 2016).
  2. Alternatives for Laravel:
  3. Quick Migration Path:
    • Install PHP-CS-Fixer:
      composer require --dev friendsofphp/php-cs-fixer
      
    • Configure .php-cs-fixer.dist.php with Symfony rules:
      return PhpCsFixer\Config::create()
          ->setRules([
              '@Symfony' => true,
              'risky_nullable_type_declaration' => false, // Adjust as needed
          ]);
      
    • Run:
      ./vendor/bin/php-cs-fixer fix
      

Implementation Patterns

Workflow Integration

  1. CI/CD Pipeline:

    • Add PHP-CS-Fixer to your GitHub Actions/GitLab CI:
      - name: Fix Coding Standards
        run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
      
    • Fail builds on violations (use --dry-run for previews).
  2. Pre-Commit Hooks:

    • Use Husky + PHP-CS-Fixer:
      composer require --dev digitalbazaar/husky-php-cs-fixer
      
    • Configure in package.json:
      "husky": {
        "hooks": {
          "pre-commit": "husky-php-cs-fixer"
        }
      }
      
  3. Team Onboarding:

    • Document the rule set in CONTRIBUTING.md:
      ## Coding Standards
      Run `composer cs-fix` to auto-fix issues. Use `@Symfony` rules unless overridden.
      
    • Pair with PSR-12 for Laravel projects.

Laravel-Specific Tips

  • Blade Templates: Exclude .blade.php files from PHP-CS-Fixer (add to .php-cs-fixer.dist.php):
    ->exclude(['storage/*', 'vendor/*', 'resources/views/*']);
    
  • Custom Rules: Extend PHP-CS-Fixer with custom rules for Laravel conventions (e.g., use App\Models\{}):
    ->withCustomFixers([new CustomLaravelFixer()]);
    

Gotchas and Tips

Pitfalls

  1. Deprecation Warning:

    • This package will not receive updates. Attempting to use it may break with modern PHP/Symfony/Laravel versions.
    • Error Example:
      Your requirements could not be resolved to an installable set of packages.
      Problem 1: m6web/symfony2-coding-standard v1.0.0 requires symfony/coding-standard ~2.0 -> found symfony/coding-standard[5.4.0] but it does not match your requirement.
      
  2. Rule Conflicts:

    • Symfony2 rules may conflict with Laravel’s conventions (e.g., namespace paths, class naming).
    • Fix: Override specific rules in .php-cs-fixer.dist.php:
      ->setRules([
          '@Symfony' => true,
          'namespace_separation' => ['custom_rule' => 'one'],
          'class_attributes_separation' => false, // Disable if using Laravel’s traits
      ]);
      
  3. Performance:

    • PHP-CS-Fixer can be slow on large codebases. Cache results:
      ./vendor/bin/php-cs-fixer fix --cache-file=.php-cs-fixer.cache
      

Debugging

  • Dry Run: Always test changes first:
    ./vendor/bin/php-cs-fixer fix --dry-run --diff
    
  • Rule-Specific Fixes: Isolate issues by testing individual rules:
    ./vendor/bin/php-cs-fixer fix --rules=@Symfony --path=app/Models/User.php
    
  • IDE Integration: Use PHP-CS-Fixer’s VSCode extension for real-time feedback.

Extension Points

  1. Custom Rule Sets:
    • Create a reusable config for your team:
      composer require --dev friendsofphp/php-cs-fixer-config
      
    • Publish a template:
      vendor/bin/php-cs-fixer-config-generator
      
  2. Parallel Processing:
    • Speed up fixes with --parallel (PHP 7.4+):
      ./vendor/bin/php-cs-fixer fix --parallel
      
  3. Integration with PHPStan:
    • Combine static analysis for deeper checks:
      composer require --dev phpstan/phpstan
      ./vendor/bin/phpstan analyse --level=5
      

Laravel-Specific Quirks

  • Facade Usage: Symfony rules may flag use App\Facades\Cache; as incorrect. Whitelist in config:
    ->setRules([
        'fully_qualified_strict_types' => true,
        'no_unused_imports' => false, // Allow Laravel facades
    ]);
    
  • Artisan Commands: Exclude app/Console/Kernel.php if it violates Symfony’s PSR-4 expectations:
    ->exclude(['app/Console/Kernel.php']);
    
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity