Composer Normalizer Package
Published on by Paul Redmond
Composer Normalize is a plugin for Composer that normalizes the composer.json file in your projects.
— Andreas Möller (@localheinz) July 1, 2021
This package exists to take the pain out of formatting and organizing the composer.json file, doing things such as:
- Restructure composer.json according to the underlying JSON schema
- Sort entries in the
bin
configuration option - Sort entries in the
config
,extra
, andscripts-descriptions
(by key) - Sort entries in the
conflict
,provide
,replace
,require
,require-dev
, andsuggest
sections - Normalize version constraints in
conflict
,provide
,replace
,require
, andrequire-dev
sections
To use this project, you can install it globally, as a composer development dependency or as a PHAR archive. Once you install the package, you have various options to use to normalize the file as you'd like:
# Defaultscomposer normalize # Indent settingscomposer normalize --indent-size=2 --indent-style=space # Dry run without making changescomposer normalize --dry-run # Run normalization and output the diffcomposer normalize --diff
You can learn more about this package, get full installation instructions, and view the source code on GitHub.