Skip to main content
Home
GrN.dk

Main navigation

  • Articles
  • Cases
  • Services
  • Your Digital Project Manager
  • About Greg Nowak
  • Image Gallery
  • Contact
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

Tidy Up composer.json with Composer Normalize

Illustrated infographic summarizing: Tidy Up composer.json with Composer Normalize

By Greg Nowak. Updated 6 August 2026.

A tidy composer.json will not fix weak dependency decisions. It will, however, make those decisions much easier to see. When formatting, key order and package lists vary from one edit to the next, a simple dependency update can produce a surprisingly noisy pull request.

For business owners and operations leads, that noise means slower reviews and less confidence in routine maintenance. For developers and agencies, it creates merge conflicts, inconsistent handovers and repeated discussions about formatting. The practical answer is to combine Composer’s own validation and sorting features with ergebnis/composer-normalize.

What each Composer tool actually does

These tools complement one another. Package sorting keeps future additions orderly, validation detects metadata and lock-file problems, and Composer Normalize applies consistent structure to the complete file.

Requirement Tool or setting Business value
Check metadata and the lock file composer validate --strict Catches avoidable release and installation problems in CI.
Sort packages added in future config.sort-packages Keeps routine dependency changes readable.
Standardize the entire file composer normalize Creates one predictable structure across contributors and projects.
Detect formatting drift composer normalize --dry-run Fails CI without silently changing repository files.
A practical division of responsibility between Composer’s built-in features and Composer Normalize.

Install Composer Normalize safely

For most applications and agency-maintained projects, install the normalizer as a development dependency. Composer plugins can execute code during Composer operations, so trust should be recorded explicitly through allow-plugins, reviewed like any other dependency and committed with the project configuration.

composer require --dev ergebnis/composer-normalize
composer config allow-plugins.ergebnis/composer-normalize true
composer normalize
composer validate --strict

The first command installs the plugin. The second allows that specific plugin instead of relying on an interactive prompt or a permissive wildcard. The final two commands normalize the file and then check its validity.

Review the proposed dependency and its source before allowing it. In an unattended build, Composer may otherwise reject an unlisted plugin rather than waiting for someone to answer a prompt. That is a useful security boundary, not an inconvenience to disable globally.

Enable package sorting for everyday work

Composer can sort package names whenever its require command changes the file. Enable that behavior in the shared project configuration:

{
  "config": {
    "sort-packages": true,
    "allow-plugins": {
      "ergebnis/composer-normalize": true
    }
  }
}

This reduces future churn, but it does not normalize the whole document. It will not impose a consistent top-level key order or clean up every manually edited section. That broader job belongs to Composer Normalize.

Enforce the result in CI

Once the initial cleanup is committed, add two non-interactive checks to the pipeline:

composer normalize --dry-run
composer validate --strict

The dry run should report the required changes and fail the job; it should not rewrite files inside CI. A developer can run composer normalize locally, review the diff and commit the result. This keeps repository changes intentional and avoids generated modifications disappearing with an ephemeral build environment.

Strict validation is useful because Composer’s normal validation can finish successfully when it finds only publishability warnings. With --strict, warnings also produce a non-zero status, which makes the command suitable for an enforced pipeline rule. For private applications, decide whether every publishability warning is relevant before making the check mandatory.

Treat composer.lock deliberately

If an application commits composer.lock, the file should remain consistent with composer.json. Composer Normalize can check that relationship and update the lock-file content hash after normalization. Review and commit that change with the normalized manifest.

The plugin also provides --no-update-lock and --no-check-lock. These are exceptions, not safer defaults. Use them only when another defined step owns lock-file validation or when a particular workflow must avoid modifying the lock file. Otherwise, suppressing both the update and the check can hide drift until installation or release.

Use the cleanup to review dependency policy

Normalization handles structure, not judgment. Once the file is easier to read, inspect the decisions that affect production:

  • Keep test runners, static-analysis tools and other development-only packages in require-dev.
  • Check PHP and extension constraints against the real production environment.
  • Remove packages left behind by retired features or integrations.
  • Prefer PSR-4 autoloading for new namespaced code where appropriate.
  • Review scripts and custom repositories whose purpose or owner is unclear.
  • Investigate platform overrides that make local dependency resolution differ from production.
  • Avoid a manually maintained version field when Composer can infer releases from version-control tags.

A formatter cannot tell you whether a constraint is too broad, an abandoned package should be replaced or a post-install script still belongs in the delivery process. Those are maintenance and ownership decisions.

Roll it out without obscuring functional changes

Normalize an established project in a dedicated pull request. Do not combine the first large formatting diff with package upgrades, changed PHP constraints or new scripts. Review and approve the mechanical baseline once; later dependency pull requests should then show only meaningful decisions.

Agencies can carry the same rule into repository templates, CI definitions and handover checklists. For a portfolio of PHP sites, that small standard makes inherited projects easier to assess and reduces review work whenever responsibility moves between people.

If dependency hygiene, pipeline rules and technical handovers keep falling between teams, Greg can help turn them into a maintainable delivery workflow.

Related on GrN.dk

  • JavaScript-Heavy Service Pages Still Lose Leads: What to Audit in 2026
  • When AI writes JSON, one bad field can break the workflow
  • Debugging PHP: A Practical Workflow for Faster Fixes

Need help with this kind of work?

Discuss your PHP delivery workflow Get in touch with Greg.

Sources

  • Composer command-line interface: validate
  • Composer configuration: sort-packages and allow-plugins
  • Composer schema
  • ergebnis/composer-normalize
Last modified
2026-08-12

Tags

  • Web
  • programming
  • php
  • Composer
  • CI

Review Greg on Google

Greg Nowak Google Reviews

 

Written recommendations from Trafik og Veje, Aarhus Municipality (2011) and AgroTech (2010) — read them on LinkedIn.

Illustrated infographic summarizing: Should publishers add Google’s new Preferred Sources button?
Should publishers add Google’s new Preferred Sources button?
2026-08-24

Google’s Preferred Sources button is worth a controlled test for eligible publishers, with careful choices around placement, performance and measurement.

Illustrated infographic summarizing: Search Console Can See TikTok Now. Your Reporting Has to Catch Up
Search Console Can See TikTok Now. Your Reporting Has to Catch Up
2026-08-23

Google can now report how social profiles appear in Search. Here is how to measure cross-channel discovery without mistaking visibility for business results.

Illustrated infographic summarizing: Your AI workflow has logs. Can they explain one bad decision?
Your AI workflow has logs. Can they explain one bad decision?
2026-08-22

Logs can show that every service worked while leaving a bad AI decision unexplained. See how connected traces and careful redaction close the gap.

Illustrated infographic summarizing: Security Questionnaires Eat Into Selling Time—Let AI Find the Evidence
Security Questionnaires Eat Into Selling Time—Let AI Find the Evidence
2026-08-21

NIS 2 is generating more supplier questionnaires. A controlled AI assistant can find approved answers and sources—and route uncertain cases for review.

Illustrated infographic summarizing: Locked out of your Apple developer account? Fix it before October 1
Locked out of your Apple developer account? Fix it before October 1
2026-08-20

Apple's updated developer agreement must be accepted by October 1, 2026, and many small app owners cannot even log in. Here is where Apple's two-factor codes really go, and how to fix your access before the deadline.

Illustrated infographic summarizing: Cloudflare Workflows Now Charges by the Step—Price the Outcome
Cloudflare Workflows Now Charges by the Step—Price the Outcome
2026-08-20

Cloudflare Workflows now bills paid plans for steps and stored state. Here is how to track cost per completed outcome without weakening reliability.

Illustrated infographic summarizing: Google’s AI Search Toggle Is a Publishing Decision, Not an SEO Setting
Google’s AI Search Toggle Is a Publishing Decision, Not an SEO Setting
2026-08-19

Google’s AI Search toggle forces a commercial choice about visibility, attribution and content use. Here’s how to make that choice responsibly.

Illustrated infographic summarizing: From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
2026-08-18

AI can reduce the work involved in processing supplier invoices, but reliable bookkeeping requires validation, duplicate checks, approval and a clear audit trail.

Illustrated infographic summarizing: Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
2026-08-17

Nginx 1.30 defaults upstream proxying to HTTP/1.1 with keepalive enabled. Here is what to inspect, model and test before upgrading.

Illustrated infographic summarizing: OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
2026-08-16

OpenAI’s Assistants API shuts down on August 26, 2026. Learn what to inventory, how to preserve state and how to cut over without breaking the product.

More articles

Built by AI — available for your business. The daily articles on this site are researched, written and illustrated by an autonomous AI pipeline. At nowa.dk I install the same kind of AI automation in businesses at fixed prices — site in Danish, English version here, and web/marketing agencies have a dedicated page.

RSS feed

Footer

  • All articles
  • Contact

GrN.dk — AI automation, web platforms, web optimization, data handling and logistics.

© 2026 GrN.dk · LinkedIn · Contact · AI automation in Danish: nowa.dk

Behind GrN.dk: Individual Entrepreneur Codecrafter · Tax ID 305669096 · Bakhtrioni St. 22, 0194 Tbilisi, Georgia · official business register