- How do I install binsoul/coding-standard for Laravel projects?
- Run `composer require binsoul/coding-standard --dev` in your Laravel project. The package installs as a dev dependency, ensuring it’s excluded from production builds. It provides a preconfigured PHP_CodeSniffer standard for immediate use.
- Does this package support Laravel’s Blade templates (.blade.php files)?
- By default, PHP_CodeSniffer ignores Blade files, but you can explicitly include them in the ruleset by modifying the `phpcs.xml` configuration. Add `<file>*.blade.php</file>` under the `<arg>` section to enforce standards on Blade templates.
- Can I customize the coding standard rules to match Laravel-specific conventions?
- Yes, the package allows customization via `phpcs.xml`. Override default rules by extending the configuration, such as allowing Laravel-specific docblock formats or adjusting naming conventions for controllers, services, or Facades.
- How do I integrate this into Laravel’s CI/CD pipeline (e.g., GitHub Actions)?
- Add a step to your CI workflow to run `./vendor/bin/phpcs --standard=Binsoul --error-severity=1 .`. For GitHub Actions, use the `error-severity` flag to fail builds on violations. Pair it with `symplify/easy-coding-standard` for richer reporting.
- Will this package conflict with other Laravel tools like laravel-pint or PHPStan?
- No direct conflicts exist, but ensure consistent tooling. Use `laravel-pint` for auto-formatting and `binsoul/coding-standard` for static analysis. PHPStan’s rules are separate, so run them independently or combine outputs in CI.
- Does binsoul/coding-standard work with Laravel Forge or Envoyer for deployment checks?
- The package itself doesn’t integrate natively with Forge/Envoyer, but you can manually run `phpcs` as a deployment hook. Add a script to your `deploy.php` (Envoyer) or Forge recipe to execute the standard before deployment.
- How do I handle false positives, like Laravel’s Route::resource() helpers or Facade usage?
- Override conflicting rules in `phpcs.xml` by excluding specific patterns. For example, ignore Facade method calls with `<exclude-pattern>.*Facade::.*</exclude-pattern>` or adjust severity for Laravel-specific constructs.
- What Laravel versions and PHP versions does this package support?
- The package doesn’t enforce Laravel version constraints, so it works with any Laravel 5.8+ project. Ensure your PHP version (e.g., 8.0+) matches Laravel’s requirements and PHP_CodeSniffer’s compatibility.
- Can I use this package with GrumPHP for pre-commit hooks?
- Yes, the package includes GrumPHP configuration. Add `phpro/grumphp-shim` and reference the package’s `grumphp.yaml` in your `composer.json` under `extra.grumphp`. Configure hooks to run `phpcs` on staged files.
- What alternatives exist for Laravel coding standards, and why choose this package?
- Alternatives include `php-cs-fixer` (for auto-fixing) or `dealerdirect/phpcodesniffer-composer-installer` (for custom standards). This package offers a preconfigured, opinionated standard tailored for Laravel, reducing setup time while maintaining flexibility.