Weave Code
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

Normalize your composer.json consistently. localheinz/composer-normalize sorts keys, formats lists, and enforces a stable structure to reduce diffs and keep projects tidy. Works well in CI and pre-commit hooks for repeatable results.

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky