- How do I install broadway/coding-standard in a Laravel project?
- Run `composer require --dev broadway/coding-standard` in your project root. This installs the coding standard as a dev dependency, allowing you to integrate it with PHP-CS-Fixer or Git hooks without affecting production.
- Does this package work with Laravel’s default PSR-12 coding standards?
- No, it enforces Broadway’s opinionated rules, which may conflict with PSR-12 (e.g., Broadway-specific naming conventions like `Event` suffixes). Use it only if your team adopts Broadway for event sourcing or explicitly needs its standards.
- Can I integrate this into Laravel’s CI pipeline (GitHub Actions/GitLab CI)?
- Yes. Add a step to run `vendor/bin/php-cs-fixer fix --rules=@Broadway` (or equivalent) in your CI workflow. Fail builds on violations or use `--dry-run` to warn first. Example: `run: vendor/bin/php-cs-fixer fix --rules=@Broadway --dry-run`.
- Will this break existing Laravel codebases that don’t use Broadway?
- Potentially. Broadway’s rules (e.g., domain-specific naming) may clash with Laravel’s conventions. Audit your codebase first or customize the rules via PHP-CS-Fixer’s config to align with your project’s needs.
- How do I configure PHP-CS-Fixer to use Broadway’s rules?
- Create a `.php-cs-fixer.php` file referencing the package’s template (`vendor/broadway/coding-standard/.php-cs-fixer.dist.php`) and set the finder to target your `src/` and `test/` directories. Example: `$config->setRules(['@Broadway' => true])`.
- Is this package compatible with Laravel 9/10 and PHP 8.0+?
- Yes, it has no direct Laravel dependencies and should work with modern PHP versions. However, test it in your environment, as Broadway’s underlying rules may assume specific PHP features or Laravel integrations.
- Can I customize or extend the coding standard rules?
- Yes, you can override or extend rules via PHP-CS-Fixer’s config. For example, modify the `.php-cs-fixer.dist.php` file to exclude Broadway-specific rules that conflict with your Laravel project’s conventions.
- What’s the difference between this and php-cs-fixer’s PSR-12 preset?
- This package enforces Broadway’s domain-driven design (DDD) conventions (e.g., event/message naming, docheader formats), while PSR-12 is generic. Use this only if you’re using Broadway or need its strict, opinionated rules.
- Does this package support docheader validation (like PHPDoc standards)?
- Yes, it includes a `docheader` tool. Copy the `.docheader.dist` template to your project root and run `vendor/bin/docheader check {src,test}` to validate PHPDoc compliance with Broadway’s standards.
- How often is this package updated, and is it actively maintained?
- The last release was in 2022, and maintenance depends on Broadway’s updates. Check the [GitHub repo](https://github.com/broadway/coding-standard) for activity. Pin the version in `composer.json` to avoid unexpected updates if stability is critical.