- How do I install this package for Laravel projects?
- Run `composer require --dev ergebnis/composer-normalize` in your Laravel project’s root. 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 existing Laravel applications?
- No, this package only modifies the formatting of `composer.json` and `composer.lock` (if configured). It doesn’t alter Laravel’s core, autoloading, or runtime behavior. Always test with `--dry-run` first in CI.
- Can I customize the normalization rules for my Laravel team?
- Yes, define team-wide defaults in `composer.json` under `extra` (e.g., `indent-size: 4`, `indent-style: space`). Override these via CLI flags if needed. Example: `composer normalize --indent-size=2`.
- Does this work with Laravel’s latest versions (e.g., Laravel 10)?
- Absolutely. This package is Laravel-agnostic and compatible with all Laravel versions. It only interacts with Composer, which Laravel relies on for dependency management. Tested with Composer ≥2.0.
- How should I integrate this into CI/CD for Laravel projects?
- Start by running `composer normalize --dry-run` in CI to preview changes. Fail builds on unnormalized files with `composer normalize || exit 1`. For GitHub Actions, add it to your workflow like any other Composer command.
- What if my team has mixed indentation (spaces/tabs) in composer.json?
- The plugin enforces consistency based on your configured `indent-style` (default: spaces). Run `composer normalize --dry-run` to see changes before enforcing it. Document exceptions in your team’s contributing guidelines.
- Are there performance concerns for large Laravel monorepos?
- Normalization is lightweight and runs during `composer install` or manually. For monorepos, specify the `composer.json` file path (e.g., `composer normalize path/to/file.json`). Benchmark with `--dry-run` to measure impact.
- Can I use this alongside Laravel’s `composer.lock`?
- Yes, but avoid normalizing `composer.lock` unless necessary (use `--no-lock` flag). The tool focuses on `composer.json` to reduce diff noise. If `composer.lock` is stale, update it first (`composer update --lock`).
- What if contributors resist strict formatting rules?
- Start with `--dry-run` in CI to show changes without blocking. Use feature flags (e.g., `composer normalize --optional`) or make it optional via `composer.json` extras. Gradually enforce it as a team norm.
- Are there alternatives for Laravel-specific composer.json formatting?
- Most alternatives (e.g., `dealerdirect/phpcodesniffer-composer`) are PHP-CS-Fixer plugins and lack Composer-native integration. This package is purpose-built for Composer, offering deeper plugin hooks and CI/CD compatibility for Laravel projects.