sylius-labs/coding-standard
Battle-tested Sylius coding standard for PHP. Install via Composer and import the provided ecs.php into your EasyCodingStandard (ECS) config to apply consistent formatting and rules across your project. Includes guidance for migrating from YAML to PHP configs.
## Technical Evaluation
### **Architecture Fit**
- **Purpose Alignment**: Remains unchanged. This is still a **coding standard configuration** for PHP (via EasyCodingStandard), enforcing PSR-12, Sylius-specific rules, and custom conventions. No functional runtime changes.
- **Non-Invasive**: Still integrates via **Composer** and **ECS configuration**, requiring no Laravel core modifications.
- **Best Practice Enforcement**: Aligns with Laravel’s PSR standards while adding Sylius-specific rules. Useful for **unified code quality** in multi-project PHP ecosystems.
### **Integration Feasibility**
- **Low Coupling**: Unchanged. No runtime behavior modification; purely a **static analysis tool**.
- **Dependency Lightweight**: Still requires `symplify/easy-coding-standard` (~50KB config).
- **Laravel Compatibility**: Works with any PHP project, including Laravel, but **new conflict with ECS v13.1.3+** (see below).
### **Technical Risk**
- **ECS Version Conflict**:
- **New Risk**: This release introduces a **conflict with ECS v13.1.3+** (PR #64). Teams using **ECS ≥13.1.3** must either:
- Downgrade ECS (`<13.1.3`), or
- **Override the conflicting rule** in their `ecs.php`.
- **Impact**: Potential **build failures** if ECS auto-updates in CI/CD.
- **False Positives/Negatives**: Still a risk due to Sylius/Laravel naming conflicts (e.g., `App\Services\*` vs. Sylius interfaces).
- **Rule Maintenance**: Sylius-specific rules may still **deprecate or evolve**, requiring updates.
- **CI/CD Pipeline Impact**: Unchanged, but now includes **version pinning risk** for ECS.
### **Key Questions**
1. **ECS Version Dependency**:
- Should the team **pin ECS to `<13.1.3`** to avoid conflicts, or **override the rule** in `ecs.php`?
- Example override:
```php
$ecsConfig->skip([ConflictRule::class]); // Hypothetical; check actual rule class.
```
2. **Rule Conflict Resolution**:
- How will Laravel’s conventions (e.g., Facades, Service Providers) interact with Sylius’s updated rules?
- Are there **new exceptions** needed for Laravel-specific patterns?
3. **Adoption Strategy**:
- Should this package **replace or supplement** existing ECS configs? (Risk of duplication with ECS v13.1.3+.)
- How will the team **handle ECS version updates** in CI/CD?
4. **Performance**:
- Will the new conflict **slow down CI/CD** if not properly overridden?
5. **Long-Term Maintenance**:
- Who will **monitor Sylius/ECS updates** and adjust the config?
- Should local overrides be **documented** for future maintainers?
---
## Integration Approach
### **Stack Fit**
- **Tooling Compatibility**:
- **ECS Integration**: Still works with `symplify/easy-coding-standard`, but **now requires version awareness** (ECS `<13.1.3` or rule overrides).
- **IDE Support**: Unchanged (PHPStorm, pre-commit hooks).
- **CI/CD**: Still pluggable, but **ECS version must be managed**.
- **Laravel-Specific Considerations**:
- **No Core Changes**: Safe to adopt, but **new risk with ECS updates**.
- **Package Overrides**: Critical for teams using ECS ≥13.1.3.
### **Migration Path**
1. **Installation** (unchanged):
```bash
composer require --dev sylius-labs/coding-standard symplify/easy-coding-standard
<13.1.3 in composer.json:
"require-dev": {
"symplify/easy-coding-standard": "^13.0 || ^12.0"
}
ecs.php:
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->import(__DIR__ . '/vendor/sylius-labs/coding-standard/ecs.php');
// TODO: Add override for the ECS v13.1.3+ conflict (check PR #64 details).
$ecsConfig->skip([/* ConflictRuleClass */]); // Hypothetical; verify actual class.
};
symplify/config-transformer).- name: Install with ECS pinned
run: composer require symplify/easy-coding-standard:^12.0
- name: Run ECS
run: composer ecs
<13.1.3 unless overridden.composer ecs:check.composer.json updates if ECS auto-updates."This package conflicts with ECS v13.1.3+. Pin to
<13.1.3or overrideConflictRuleinecs.php."
composer ecs --debug.--parallel and caching.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| ECS ≥13.1.3 fails CI pipeline | Blocked merges | Pin ECS or override the conflicting rule. |
| Rule conflicts with Laravel | Manual overrides needed | Document exceptions in ecs.php. |
| Outdated Sylius rules | Broken builds after package update | Pin version or update rules proactively. |
| Slow CI execution | Flaky pipelines | Cache ECS results, run in parallel. |
| New: ECS auto-updates in CI | Unexpected failures | Pin ECS version in composer.json or CI. |
<13.1.3 or add skip([ConflictRule]) to ecs.php."ECS_RULES.md to include:
How can I help you explore Laravel packages today?