Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Composer Normalize

Composer Normalize Laravel Package

localheinz/composer-normalize

A Composer plugin that normalizes composer.json files, so you don't have to format them manually or ask contributors to fix inconsistent ordering and whitespace. Install it as a dev dependency and let it keep your package manifest consistently formatted.

View on GitHub
Deep Wiki
Context7

Provides a composer plugin for normalizing composer.json.

Frequently asked questions about Composer Normalize
How do I install and use composer-normalize in a Laravel project?
Install it globally with `composer global require localheinz/composer-normalize`, then run `composer normalize` in your Laravel project directory. It works as a Composer plugin, so no Laravel-specific setup is needed. For CI/CD, add it as a pre-install step in your pipeline.
Will this break my existing composer.json or Laravel dependencies?
No, the tool is idempotent—repeated runs produce the same output. It only sorts keys, formats lists, and enforces structure without altering dependency versions or Laravel-specific configurations. Always test with `composer normalize --dry-run` first.
Can I customize which parts of composer.json are normalized?
Yes, use a `.composer-normalize.json` config file to exclude sections (e.g., `extra.laravel`) or define custom sorting rules. This is useful for Laravel projects where certain sections like `scripts` or `config` should remain unchanged.
Does this work with Laravel’s extra.laravel section?
By default, the tool normalizes all sections, including `extra.laravel`. To preserve custom ordering or exclude it, add `extra.laravel` to the `exclude` array in your `.composer-normalize.json` config file.
How can I integrate this into GitHub Actions for Laravel CI?
Add a step like `- run: composer normalize --check` before `composer install` in your workflow. This ensures `composer.json` matches the normalized format, preventing inconsistent merges. Use `--check` to fail the build if files differ.
Is this compatible with Laravel 10 and Composer 2.x?
Yes, the package supports Composer 2.x (used by Laravel 8+) and Composer 1.x. It’s framework-agnostic but particularly useful for Laravel projects where dependency consistency is critical. Tested with modern Laravel versions.
What if my team relies on specific composer.json formatting (e.g., alphabetized require-dev)?
The tool respects your preferred order by default. If you want alphabetized sections, configure it via `.composer-normalize.json` with custom sorting rules. Run `composer normalize --dry-run` to preview changes before enforcing them.
Can I use this in a monorepo with multiple Laravel packages?
Absolutely. Run `composer normalize` in the root directory to standardize all `composer.json` files across packages. This reduces diff noise and ensures consistency in dependency management for large Laravel monorepos.
Are there alternatives to this package for Laravel projects?
Other tools like `composer-merge-plugin` or `composer-normalize` (by different authors) exist, but this one focuses specifically on formatting and sorting without merging. For Laravel, this is ideal for CI/CD consistency, while tools like `roave/security-advisories` handle security checks.
How do I handle false positives in CI (e.g., unnecessary diffs from normalization)?
Start with `--dry-run` to preview changes, then commit the normalized `composer.json` to your repo. This ensures CI only flags *actual* inconsistencies. For Laravel, exclude sections like `extra.laravel` if they’re intentionally unordered.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator