- How do I enforce lean releases for my Laravel package using Lean Package Validator?
- Add it as a dev dependency (`composer require --dev stolt/lean-package-validator`) and run `composer validate-gitattributes` in your `composer.json` scripts. Use the `--preset=PHP` flag to align with Laravel conventions, which excludes common dev files like `.github/`, `.idea/`, and `vendor/`.
- Will Lean Package Validator work with Laravel 10/11 projects?
- Yes, it supports PHP 8.2+, which covers Laravel 10/11. For Laravel-specific exclusions (e.g., `storage/logs/` or `bootstrap/cache/`), use `--keep-glob-pattern` to override defaults or contribute to the PHP preset via a PR to the package.
- Can I integrate Lean Package Validator into GitHub Actions for CI/CD?
- Absolutely. Add a step like `- run: composer validate-gitattributes -- --validate-git-archive` to your workflow. Fail the build if validation catches unwanted files, ensuring clean releases. Works seamlessly with Laravel’s CI pipelines.
- What if Lean Package Validator flags false positives (e.g., excluding `config/` in Laravel)?
- Use `--keep-glob-pattern '{config/}'` to preserve critical directories. Alternatively, create a custom `.lpv` config file to define exceptions. The tool prioritizes flexibility while enforcing leanness.
- Does Lean Package Validator slow down CI for large Laravel projects?
- The `--validate-git-archive` command creates temporary archives, which may add minor overhead. Test performance in your CI with a sample Laravel monorepo (e.g., including `vendor/`). For large repos, consider running it only on release branches.
- How does Lean Package Validator compare to Laravel’s `exclude-from-classmap` in composer.json?
- Lean Package Validator enforces *release-time* exclusions via `.gitattributes`, while `exclude-from-classmap` targets *runtime* class loading. Use both: lpv for lean distributions and `exclude-from-classmap` for runtime optimizations. lpv also auto-generates `.gitattributes` rules.
- Can I use Lean Package Validator to validate `.gitattributes` in a Laravel monorepo (e.g., Sail or Valet)?
- Yes. Run `composer validate-gitattributes` in each sub-package or root directory. The tool detects inconsistencies across repositories. For monorepos, use `--preset=PHP` and manually add Laravel-specific paths (e.g., `sail/`, `valet/`) via `--keep-glob-pattern`.
- How do I create a custom Artisan command to wrap Lean Package Validator for Laravel?
- Extend Laravel’s command system with a `GitAttributesValidator` command. Use `Shell::run()` to call `lean-package-validator validate`. Example: `php artisan validate:gitattributes` could run `lpv validate --preset=PHP --validate-git-archive` with Laravel-specific defaults.
- What are the risks of using Lean Package Validator in production deployments?
- Minimal risks if configured correctly. Always test `.gitattributes` changes in staging first. Use `--validate-git-archive` pre-deployment to catch leaks (e.g., `storage/logs/`). Avoid excluding runtime-required files like `config/` or `public/`.
- Are there alternatives to Lean Package Validator for Laravel packages?
- For basic exclusions, `git-archive-all` or manual `.gitattributes` work, but lack automation. Laravel’s `exclude-from-classmap` handles runtime optimizations only. Lean Package Validator uniquely combines validation, auto-generation, and Laravel-specific presets for a streamlined workflow.