- How do I install this PHP-CS-Fixer config for Laravel projects?
- Run `composer require --dev prooph/php-cs-fixer-config` and add it to your project’s `.php-cs-fixer.php` config file. The package provides a ready-to-use ruleset that integrates seamlessly with Laravel’s existing toolchain.
- Does this config work with Laravel’s default PSR-12 rules?
- No, this config prioritizes prooph’s DDD/CQRS conventions (e.g., event naming, event store patterns) over PSR-12. You’ll need to merge configs or override conflicting rules like `array_syntax` or `class_attributes` to avoid clashes.
- Can I use this in CI/CD pipelines like GitHub Actions?
- Yes. Add a step to run `php-cs-fixer fix --config=.php-cs-fixer.php --dry-run` in your workflow. Cache the `.php-cs-fixer.cache` file to speed up execution, especially for large codebases.
- What Laravel versions does this package support?
- This package has no direct Laravel dependency but requires PHP 8.0+. It’s compatible with Laravel 9+ (PHP 8.0+) and works alongside Laravel’s default tooling like Valet, Sail, or Pint with minor adjustments.
- How do I handle prooph-specific patterns that conflict with PHP-CS-Fixer?
- Document exceptions in your team’s style guide. For example, prooph’s event sourcing annotations (e.g., `@Event`) may trigger false positives. Override rules in your `.php-cs-fixer.php` or use `ignore` patterns for known cases.
- Should I enforce this config in pre-commit hooks?
- Yes, but start gradually. Use it as a pre-commit hook (e.g., with Husky) to catch style issues early, but avoid blocking merges initially. Enforce it strictly in CI/CD pipelines first to minimize disruption.
- What if prooph updates their config and breaks my project?
- Pin to a specific version (e.g., `^1.0`) or fork the package if needed. Monitor prooph’s releases for rule changes and test updates in a staging environment before adopting them globally.
- Does this config support Laravel Mix or Pint?
- Yes, but you may need to exclude prooph-specific rules that conflict with Laravel’s defaults. For Pint, extend its config with prooph’s ruleset. For Mix, use a custom Webpack plugin or run PHP-CS-Fixer separately.
- How do I customize the header template for prooph’s copyright notice?
- Create a `.docheader` file in your project root with the provided template. The config will automatically inject it into your PHP files. You can modify the template to match your project’s licensing requirements.
- Are there alternatives to this config for Laravel projects?
- Yes, but most alternatives (e.g., `laravel/php-cs-fixer`) focus on PSR-12. For DDD/CQRS projects, this config is tailored to prooph’s conventions, including event naming, aggregate roots, and event store patterns. Consider merging it with Laravel’s defaults if needed.