- Is symplify/coding-standard still recommended for new Laravel projects?
- No, this package is deprecated. Use **Easy Coding Standard (ECS)** instead, which includes these rules natively. Migrate by replacing `symplify/coding-standard` with ECS’s `symplify` preset in your `ecs.php` config. The transition is seamless and future-proof.
- How do I install and run this in a Laravel project?
- Install via Composer: `composer require symplify/easy-coding-standard --dev`. Configure ECS in `ecs.php` with `->withPreparedSets('symplify')`. Run with `vendor/bin/ecs` (dry-run) or `vendor/bin/ecs --fix` to auto-correct. Works as a dev dependency with no runtime impact.
- Does this enforce Laravel-specific coding standards like PSR-12?
- Yes, it aligns with **PSR-12** (Laravel’s default standard) out of the box, including docblock formatting, array syntax, and strict types. It also handles Laravel idioms like promoted properties and constructor parameters. No Laravel-specific config is needed for basic usage.
- Can I customize the rules, or is it all-or-nothing?
- While the preset requires no config, you can override individual rules in `ecs.php`. For example, adjust `LineLengthFixer` or disable `ArrayListItemNewlineFixer` if your team prefers compact arrays. Use `->with()` to modify the config after loading the preset.
- Will this break existing PHP-CS-Fixer or PHP_CodeSniffer setups?
- Potentially. Run `vendor/bin/ecs --dry-run` first to compare output with your current tool. Some rules (e.g., line length, array formatting) may conflict. Use `->with()` to align ECS rules with your existing conventions before full adoption.
- How does this integrate with Laravel’s CI/CD pipelines?
- Add it to your CI (e.g., GitHub Actions) with a step like `php vendor/bin/ecs check src --no-progress-bar`. Fail builds on violations or use `--fix` to auto-correct. For pre-commit hooks, pair it with **Husky** to enforce fixes locally before commits.
- Does this work with Laravel 8/9/10 and Lumen?
- Yes, it’s compatible with **Laravel 8+** and Lumen. For full feature support, use **PHP 8.0+**. Tested in production environments with Laravel Forge and Homestead. No core framework modifications are required—it runs as a standalone dev tool.
- What if my team has custom coding standards not covered here?
- ECS is highly extensible. You can **add custom rules** or combine presets (e.g., `symplify` + `psr12`). For Laravel-specific needs, extend ECS with your own fixers or use the `@phpstan-`/`@psalm-` annotations to integrate with static analyzers like PHPStan.
- How do I handle conflicts with IDEs like PHPStorm or VSCode?
- Use the **ECS plugin for PHPStorm** or configure VSCode’s **PHP Intelephense** to recognize ECS rules. For auto-formatting, set up IDE shortcuts to run `vendor/bin/ecs --fix` on save. This ensures consistency between your editor and CI pipeline.
- What’s the migration path if I’m already using PHP-CS-Fixer?
- Start by running both tools side-by-side (`php-cs-fixer` and `ecs`) to compare outputs. Map common rules (e.g., `array_indentation` → `ArrayNotationFixer`) and update your CI/CD scripts. Gradually replace `php-cs-fixer` with ECS, using `--fix` to resolve discrepancies incrementally.