- How do I install woohoolabs/coding-standard for Laravel?
- Run `composer require --dev woohoolabs/coding-standard` in your Laravel project. The package provides a `phpcs.xml` config file—copy it to your project root and run `phpcs` to enforce rules. Requires PHP 7.4+ (PHP 8.1+ recommended for full slevomat v8 support).
- Does this package support Laravel Blade templates?
- The package primarily targets PHP files, but slevomat v8 may include Blade-specific rules (e.g., `@foreach` indentation). Check the `phpcs.xml` for Blade exclusions or whitelist `resources/views/` if rules conflict. No native Blade linting is guaranteed.
- What Laravel versions are compatible with this coding standard?
- Works with Laravel 9+ (PHP 8.1+ recommended) and Laravel 10+. For Laravel 8.x, upgrade PHP to 8.1+ first. Older Laravel versions (<9) may require manual adjustments for slevomat v8’s stricter PSR-12 rules.
- Are there breaking changes from slevomat v7 to v8?
- Yes. slevomat v8 introduces stricter PSR-12 compliance, PHP 8.1+ features (e.g., named args), and may deprecate older rules like PSR-1/PSR-2. Run `php-cs-fixer fix --dry-run --rules=@WoohooLabs` to audit violations before migrating.
- Can I integrate this with PHP-CS-Fixer?
- Absolutely. Use PHP-CS-Fixer v3+ with the `@WoohooLabs` rule set. Update your `.php-cs-fixer.dist.php` to include `WoohooLabs` rules, then run `php-cs-fixer fix`. The package aligns with slevomat’s recommended tooling.
- Will this conflict with Laravel’s default coding style?
- Minimal risk, but stricter rules (e.g., disallowing `var_dump` in production) may clash. Review the `phpcs.xml` for Laravel-specific exceptions. Test in a staging environment first to identify edge cases like Artisan command output formatting.
- Does this package support PHP 8.2 features like new attributes?
- Yes, slevomat v8 supports PHP 8.2’s attributes and first-class callable syntax. The package enforces PSR-12 compliance for these features, so ensure your Laravel project (v10+) and PHP version align.
- How do I customize rules for my Laravel project?
- Extend the provided `phpcs.xml` by adding `<exclude>` tags for Laravel-specific files (e.g., `bootstrap/cache/`) or overriding rules. For PHP-CS-Fixer, modify `.php-cs-fixer.dist.php` to adjust line lengths, indentation, or Blade template rules.
- Are there performance improvements in slevomat v8?
- Yes, slevomat v8 optimizes static analysis for PHP 8.1+, reducing runtime overhead. Pair with PHP-CS-Fixer v3 for faster fixes. Benchmark in CI/CD pipelines—most projects see 20–30% speedups compared to v7.
- What alternatives exist for Laravel code standards?
- Consider `laravel-shift/coding-standard` (Laravel-specific rules) or `dealerdirect/phpcodesniffer-composer-installer` for auto-installing standards. For stricter PSR-12, use `slevomat/coding-standard` directly. WoohooLabs’ package adds Doctrine-inspired rules on top of slevomat.