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.
.gitattributes validation, reducing release artifact bloat (e.g., dev files, IDE configs, caches). Aligns with trends toward minimal, dependency-light packages (e.g., micro-libraries, CLI tools)..gitattributes or manual checks. Build only if needing custom artifact exclusion rules beyond PHP presets (e.g., multi-language repos).vendor/, .idea/ from published packages).LICENSE.md) are excluded by default unless explicitly kept, mitigating legal risks in automated releases..gitattributes via init/create commands.--diff) to debug misconfigurations..env, composer.lock) from accidental inclusion in releases, aligning with secrets management best practices..gitattributes management.git archive --list + manual checks)..gitattributes changes (e.g., pre-commit + custom script).exclude-files config).*"This tool automates the enforcement of 'lean package' principles—reducing the size and complexity of our released artifacts by excluding dev files (e.g., IDE configs, test caches) from distribution. For example, it can cut a PHP package’s release size by 30–50% by omitting vendor/, .idea/, and node_modules/. This aligns with our goals to:
.env, composer.lock)..gitattributes files, saving engineering time.It’s a low-effort, high-impact fix for a common pain point in open-source and internal package management. The PHP ecosystem already uses it; we can adopt it as a standard step in our CI/CD pipeline."*
*"Problem: Our released packages often include unnecessary files (e.g., vendor/, .phpunit.result.cache), bloating downloads and increasing support overhead for users who accidentally include dev dependencies.
Solution: stolt/lean-package-validator is a CLI tool that:
.gitattributes files to ensure standard dev artifacts are excluded from releases..gitattributes with best-practice rules (e.g., ignore bin/, .github/, tests/).composer validate-gitattributes).Why now?
composer.lock, .env, etc.Proposal:
composer.json as a dev dependency:
"scripts": {
"validate-gitattributes": "lean-package-validator validate"
}
- name: Validate lean package
run: composer validate-gitattributes
lpv init to standardize .gitattributes across repos.Impact: Faster releases, smaller artifacts, and fewer user complaints about ‘unexpected files.’"*
*"Tired of manually editing .gitattributes or discovering vendor/ in your published package? Lean Package Validator (LPV) automates this with a few commands:
.gitattributes excludes the right files:
lpv validate
.gitattributes:
lpv create # New file
lpv update # Overwrite existing
lpv validate --diff
lpv init --preset=Python
Pro Tip: Add to your composer.json to run on every release:
"scripts": {
"post-release": "lpv validate --validate-git-archive"
}
This ensures your git archive matches your .gitattributes—no surprises!"*
How can I help you explore Laravel packages today?