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
Lean Package Validator

Lean Package Validator Laravel Package

stolt/lean-package-validator

CLI tool to validate a PHP project/micro-package for “leanness” by ensuring common repo artifacts aren’t shipped in release archives. Also creates and updates .gitattributes export-ignore entries to enforce lean release assets.

View on GitHub
Deep Wiki
Context7

Lean Package Validator (lpv) is a CLI utility that checks whether a PHP project/micro‑package is truly lean—meaning common repository artifacts won’t be shipped in release archives. It helps you keep distributions clean and professional by validating export rules before tagging a release.

It can also generate and maintain the .gitattributes export-ignore entries that enforce leanness across your repo.

  • Validates a package for leanness (release assets stay minimal)
  • Detects unwanted artifacts that could end up in exports
  • Creates .gitattributes export-ignore rules automatically
  • Updates existing export-ignore rules to stay consistent
  • Works as a global CLI or as a dev dependency for CI/Composer scripts
Frequently asked questions about Lean Package Validator
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.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport