- How do I install lean-package-validator in a Laravel project?
- Run `composer require --dev stolt/lean-package-validator` to add it as a dev dependency. The CLI tool will be available via `vendor/bin/lean-package-validator` or globally if installed via `composer global require`. Add it to your `composer.json` scripts for automated validation, like `"validate-lean": "lean-package-validator validate"`.
- Does this tool work with Laravel 10+ and PHP 8.2+?
- Yes, the package is fully compatible with Laravel 10+ and PHP 8.2+. It has no framework-specific dependencies and integrates seamlessly with modern Composer workflows. Check the [README](https://github.com/raphaelstolt/lean-package-validator) for version-specific details.
- Can I enforce lean releases in GitHub Actions for my Laravel package?
- Absolutely. Add a step like `- name: Validate Lean Package
run: composer validate-lean` to your GitHub Actions workflow. This ensures `.gitattributes` and excluded files are validated before every release, blocking non-lean artifacts from being distributed.
- What if my Laravel project has custom vendor paths or monorepo setups?
- The tool supports monorepos by targeting specific directories. For custom vendor paths (e.g., in monorepos), explicitly define them in your `.gitattributes` or use a custom `.lpv` preset. Laravel’s default `vendor/` is auto-handled, but edge cases may require manual glob pattern adjustments.
- Will this tool conflict with Laravel’s default ignored files (e.g., node_modules, storage)?
- No, but you may need to tune glob patterns in `.gitattributes` to avoid false positives. Laravel’s default ignored files (like `node_modules/`) are typically excluded by default. Test locally with `composer validate-lean` and adjust rules as needed.
- How do I create or update .gitattributes for lean releases?
- Use the `create` or `update` commands: `lean-package-validator create` generates a `.gitattributes` file with lean defaults, while `update` modifies existing entries. For Laravel, you can extend presets via a custom `.lpv` file to include/exclude specific paths like `bootstrap/cache/` or `routes/`.
- Should I run validation on every commit or only on release branches?
- For CI/CD efficiency, gate validation to release branches (e.g., `main` or `release/*`). Running it on every commit can be noisy, but pre-commit hooks (via `composer.json` scripts) are useful for local enforcement. Configure CI to block failures or warn based on your team’s workflow.
- Can I integrate this into Laravel’s Artisan commands?
- Yes, wrap the validator in a custom Artisan command (e.g., `php artisan lpv:validate`) by extending Laravel’s `Command` class. This provides tighter integration with Laravel’s ecosystem, especially for teams using Artisan for package management.
- What are the performance implications of running this in CI?
- The `--validate-git-archive` command creates temporary archives, which may slow down CI for large repos. Mitigate this by running it only on critical paths (e.g., release branches) or caching `.gitattributes` between runs. For small-to-medium Laravel packages, overhead is minimal.
- Are there alternatives to this tool for Laravel packages?
- Alternatives include manual `.gitattributes` configuration or tools like `git-archive-all` with custom filters. However, `lean-package-validator` offers preset-based validation (PHP, Python, etc.), Laravel-specific tuning, and CLI/CI integration out of the box. For Laravel, consider extending its presets via `.lpv` files for framework-specific rules.