chrisjenkinson / symfony-service-sorter
Sorts entries in the services: key of Symfony YAML files alphabetically
Package info
github.com/chrisjenkinson/symfony-service-sorter
pkg:composer/chrisjenkinson/symfony-service-sorter
Requires
- php: ^8.2
- symfony/console: ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- infection/infection: ^0.32
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.0 || ^11.0
- symplify/easy-coding-standard: ^12.0
This package is auto-updated.
Last update: 2026-05-17 03:16:35 UTC
README
CLI for checking and fixing service ordering in Symfony services: YAML files.
What it does
symfony-service-sorter helps keep Symfony service definitions in a consistent order.
It provides:
checkto report out-of-order servicesfixto rewrite a file into the expected order
Installation
Install it as a development dependency:
composer require --dev chrisjenkinson/symfony-service-sorter
The binary is available at vendor/bin/sort-services.
Usage
Run the binary with a subcommand and one or more target YAML files:
vendor/bin/sort-services <command> <path-to-yaml-file>...
Check
vendor/bin/sort-services check config/services.yaml
check exits successfully when services are already in order and reports ordering problems otherwise.
You can also check more than one file in one invocation:
vendor/bin/sort-services check config/services.yaml config/services_test.yaml
Fix
vendor/bin/sort-services fix config/services.yaml
fix rewrites files in place only when sorting changes their contents. Files that are already sorted are reported as Unchanged.
You can also fix more than one file in one invocation:
vendor/bin/sort-services fix config/services.yaml config/services_test.yaml
To print the sorted output instead, use:
vendor/bin/sort-services fix config/services.yaml --stdout
--stdout only supports a single file.
Compatibility
- PHP
^8.2 - Symfony Console
^6.0 || ^7.0 || ^8.0
Development
Useful local verification commands:
vendor/bin/phpunit vendor/bin/ecs check vendor/bin/phpstan analyse vendor/bin/infection --threads=max --min-msi=85 --min-covered-msi=85
License
GPL-3.0-or-later