symplify/easy-coding-standard
Easy Coding Standard (ECS) makes PHP coding standards effortless on PHP 7.2–8.5. Fast parallel runs, supports PHP_CodeSniffer and PHP-CS-Fixer, uses prepared rule sets, generates ecs.php config on first run, and can check and auto-fix code with --fix.
symplify/coding-standard dependency suggests compatibility with Laravel’s ecosystem.composer require symplify/easy-coding-standard --dev. Minimal setup (e.g., ecs.php config) leverages Laravel’s existing Composer workflow.PSR_12 and layer Laravel-specific rules (e.g., Symplify\EasyCodingStandard\RuleSet\LaravelRuleSet) as needed. Config validation and IDE autocompletion (via ECSConfig) reduce errors.php-cs-fixer/phpcs commands with vendor/bin/ecs check in pipelines. Output formats (e.g., GitLab/Checkstyle) integrate with Laravel’s CI tools (GitHub Actions, GitLab CI).symfony/console version mismatches). ECS’s use of squizlabs/php_codesniffer:^4.0 may conflict with Laravel’s bundled php-codesniffer (if used).config/array.php). Requires rule whitelisting/blacklisting.FnMatchPathNormalizer) could impact low-memory environments.app/Providers/, Blade syntax, Eloquent naming)?symfony/* dependencies?use statements in Blade files") beyond PSR-12?--dry-run) to avoid accidental breakages?.blade.php, Artisan commands) without false positives/negatives?gitlab, checkstyle).ecs.php autocompletion.php-cs-fixer (if used) with a faster, unified tool.app/ structure via path configuration (e.g., paths([__DIR__.'/app'])).php_cs.dist/.php_cs and PHP-CS-Fixer configs for Laravel-specific rules.composer require symplify/easy-coding-standard --dev
vendor/bin/ecs init # Generates ecs.php with PSR-12 defaults
ecs.php:
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__.'/app',
__DIR__.'/config',
__DIR__.'/routes',
]);
$ecsConfig->sets([
SetList::PSR_12,
// Laravel-specific (if available)
// SetList::LARAVEL,
]);
// Whitelist/blacklist rules as needed
$ecsConfig->ruleWithConfiguration(
\Symplify\EasyCodingStandard\Rule\Commenting\InlineTodoRule::class,
['skip' => ['**/Tests/*']]
);
};
--fix to resolve issues:
vendor/bin/ecs check --fix --parallel --no-interaction
Symplify\EasyCodingStandard\Rule\Naming\ExplicitStringClassRule)..github/workflows/ or gitlab-ci.yml:
- name: Run ECS
run: vendor/bin/ecs check --no-diffs --format=gitlab
vendor/bin/ecs check app/Http).@foreach loops).symfony/console). Use composer why symfony/console to resolve conflicts.php artisan ecs) for local runs.Settings > Languages & Frameworks > PHP > Code Sniffer).php-cs-fixer/php-codesniffer requires periodic updates (e.g., v13.x’s squizlabs/php_codesniffer:^4.0). Use composer update symplify/easy-coding-standard cautiously.ecs.php or rule set for Laravel-specific conventions (e.g., app/Providers/ naming).ContainerConfigurator deprecation in favor of ECSConfig).skip or custom rules.How can I help you explore Laravel packages today?