- How do I install this package for a Laravel project?
- Run `composer require --dev ergebnis/composer-normalize` to add it as a dev dependency, then enable the plugin with `composer config allow-plugins.ergebnis/composer-normalize true`. No Laravel-specific setup is needed—it works globally with Composer.
- Will this break my Laravel application if I run it?
- No, this plugin only normalizes formatting (e.g., key ordering, indentation) and doesn’t alter functionality. It’s safe to run in CI or locally without affecting runtime behavior.
- Does this work with Laravel’s monorepo structure or multi-package projects?
- Yes, run it in the root directory to normalize all sub-packages’ `composer.json` files. Use the `--file` flag to target specific files, like `composer normalize --file=packages/*/composer.json`.
- Can I customize which keys or sections are normalized?
- The plugin supports exclusions via configuration. For example, if your Laravel project uses custom `extra.laravel` keys, you can exclude them by setting `normalization.exclude` in your `composer.json` config.
- How do I integrate this into GitHub Actions for Laravel?
- Add a step to your workflow: `- name: Normalize composer.json run: composer normalize --dry-run`. Fail the job on diffs (exit code 1) to block merges with inconsistent formatting. Works seamlessly with Laravel’s CI pipelines.
- Does this support older Laravel/Composer versions (e.g., Composer v1)?
- The package officially supports Composer v2+, but you can test it with v1. However, plugins weren’t fully supported in Composer v1, so functionality may be limited. Laravel 5.8+ (Composer v2+) is recommended.
- What if my team has custom composer.json formatting (e.g., non-standard keys)?
- Use the `--exclude` flag or configure `normalization.exclude` in your `composer.json` to skip specific keys or sections. The plugin defaults to a widely accepted standard but allows customization.
- How does this compare to manually formatting composer.json or using php-cs-fixer?
- Unlike manual formatting or php-cs-fixer, this plugin enforces *consistent* key ordering and structure across all contributors. It’s faster, repeatable, and integrates directly into Composer’s workflow, reducing noisy diffs in Laravel repos.
- Can I run this locally before committing to avoid CI failures?
- Yes, use `composer normalize --dry-run` locally to preview changes. Add it to a pre-commit hook (e.g., Husky) to block inconsistent formatting before it reaches CI, saving time for your Laravel team.
- What are the performance implications of running this in CI for large Laravel repos?
- Normalization is lightweight, but large repos (e.g., Laravel Framework) may add ~10–30 seconds to CI. Cache results or run in parallel. For most Laravel projects, the overhead is negligible compared to the benefits of consistency.