stolt/lean-package-validator
CLI tool to validate a project or micro-package for “leanness” by ensuring common repo artifacts are excluded from release archives. Also creates, updates, and reformats .gitattributes export-ignore entries for lean distribution packages.
.gitattributes (a native Git feature), reducing dependency on custom tooling. Works seamlessly with Laravel’s existing Git workflows (e.g., git archive).vendor/, bootstrap/) could be added via custom .lpv files.composer.json scripts, enabling automated validation during builds/deploys.composer require --dev stolt/lean-package-validator).pre-commit or pre-push hooks (via composer.json scripts) to enforce lean releases before code is merged or deployed.# GitHub Actions
- name: Validate Lean Package
run: composer validate-gitattributes
php artisan lpv:validate)..gitattributes rules might conflict with Laravel’s default ignored files (e.g., node_modules/, storage/). Requires careful tuning of glob patterns.--validate-git-archive creates temporary archives, which could slow down CI pipelines for large repos. Mitigate by running only in critical paths (e.g., main branch).export-ignore feature; teams unfamiliar with .gitattributes may need training. Document usage clearly in the project’s CONTRIBUTING.md.vendor/ directory is auto-generated and often excluded, but custom vendor paths (e.g., in monorepos) might need explicit handling.bootstrap/cache/, config/) be explicitly allowed or excluded?storage/framework/views)?.lpv preset for Laravel (e.g., including routes/, app/Providers)?README.md in releases) with practicality (e.g., allowing CHANGELOG.md)?make:package or make:command scaffolding?composer.json for lean dependencies (e.g., no require-dev in production)?composer.json scripts, GitHub Actions, and Forge deployments.phpunit, phpstan, and pest by ensuring their configs (e.g., phpunit.xml.dist) are excluded from releases.composer require --dev stolt/lean-package-validator
composer.json:
"scripts": {
"validate-lean": "lean-package-validator validate"
}
composer validate-lean and adjust .gitattributes as needed.- name: Validate Lean Package
run: composer validate-lean
CHANGELOG.md allowed in releases) in the project’s CONTRIBUTING.md.vendor/, node_modules/), but may need tweaks for:
storage/app/public)..env.example vs. .env).--keep-glob-pattern to whitelist exceptions:
lean-package-validator validate --keep-glob-pattern '{CHANGELOG.md,.env.example}'
.gitattributes:
update command can migrate existing files to the lean format:
lean-package-validator update --dry-run
--diff to preview changes:
lean-package-validator validate --diff
lean-package-validator validate packages/auth
lean-package-validator init to create a .lpv file with Laravel-specific patterns..lpv file or use --preset=PHP as a starting point.--validate-git-archive to catch accidental inclusions in releases.--report-stale-export-ignores to clean up unused rules.composer.json scripts and CI pipelines.pre-release hooks to validate before publishing to Packagist.LEAN_PACKAGE_GUIDE.md in the repo explaining:
.gitattributes for Laravel.CHANGELOG.md).bootstrap/cache/)..gitattributes rules (e.g., from IDEs like PHPStorm).--diff to debug discrepancies.--keep-glob-pattern.lean-package-validator.# Fix a validation failure
lean-package-validator update --dry-run # Preview changes
lean-package-validator update # Apply changes
git add .gitattributes
git commit -m "Fix lean package validation"
--validate-git-archive is the most resource-intensive operation. Mitigate by:
main.How can I help you explore Laravel packages today?