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 Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Lean Package Philosophy: The package aligns well with Laravel/PHP ecosystems where minimizing release artifacts (e.g., dev files, IDE configs, caches) is critical for performance and security. It enforces Git export-ignore rules, which are directly applicable to Laravel projects (e.g., .env, node_modules, vendor/).
  • Composer Integration: Since Laravel relies heavily on Composer, the package’s CLI and Composer script hooks fit seamlessly into build pipelines (e.g., post-release, pre-publish).
  • Preset Support: The built-in presets (PHP, Python, etc.) reduce configuration overhead for Laravel-specific paths (e.g., .idea/, .phpunit.result.cache).

Integration Feasibility

  • Low Friction: The package can be integrated via:
    • Composer scripts (e.g., composer validate-gitattributes).
    • CI/CD hooks (GitHub Actions, GitLab CI) to block non-lean releases.
    • PHAR distribution for air-gapped environments.
  • Laravel-Specific Use Cases:
    • Validate .gitattributes in monorepos (e.g., Laravel + Vue/React).
    • Enforce lean releases for packages published via Packagist.
  • Tooling Synergy: Works with existing Laravel tooling (e.g., phpunit, php-cs-fixer) to ensure dev artifacts are excluded.

Technical Risk

  • False Positives/Negatives:
    • Custom .gitattributes rules may conflict with the package’s defaults (mitigated by --glob-pattern or .lpv files).
    • Risk: Overly strict validation could break legacy workflows (e.g., projects requiring vendor/ in releases).
    • Mitigation: Use --dry-run and --diff to preview changes.
  • Performance:
    • Risk: --validate-git-archive creates temporary archives, which could slow down CI pipelines for large repos.
    • Mitigation: Cache results or run in parallel with other checks.
  • Dependency Stability:
    • Risk: The package is actively maintained (last release: 2026), but Laravel’s evolving tooling (e.g., Laravel 13+) may introduce new dev artifacts.
    • Mitigation: Monitor updates and extend presets via .lpv files.

Key Questions

  1. Scope of Validation:
    • Should the package validate only Laravel-specific paths (e.g., .env, storage/logs) or all dev artifacts?
    • Trade-off: Narrow scope reduces false positives but may miss edge cases.
  2. CI/CD Integration:
    • How to enforce validation without blocking merges (e.g., allow --keep-glob-pattern for specific files)?
  3. Customization:
    • Should teams use .lpv files or override presets via CLI flags?
    • Example: A Laravel project might need to keep storage/framework/cache/ in releases.
  4. Performance:
    • For large repos (e.g., Laravel SaaS apps with 10K+ files), how to optimize --validate-git-archive?
  5. Toolchain Compatibility:
    • Does the package conflict with other Git tools (e.g., git-archive-all) used in Laravel workflows?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Composer: Native integration via composer.json scripts (e.g., post-release).
    • CI/CD: GitHub Actions (dedicated action available), GitLab CI, or CircleCI.
    • PHAR: Useful for Docker-based Laravel deployments.
  • Tooling Compatibility:
    • Works alongside:
      • phpunit (exclude .phpunit.result.cache).
      • laravel-mix/vite (exclude node_modules/).
      • php-cs-fixer (exclude .php-cs-fixer.php).
  • Monorepos:
    • Supports multi-package repos (e.g., Laravel + API packages) via directory-specific .lpv files.

Migration Path

  1. Pilot Phase:
    • Step 1: Add to composer.json as a dev dependency:
      "require-dev": {
        "stolt/lean-package-validator": "^3.3"
      }
      
    • Step 2: Add a Composer script:
      "scripts": {
        "validate-gitattributes": "lean-package-validator validate --preset=PHP"
      }
      
    • Step 3: Test locally with --dry-run:
      composer validate-gitattributes -- --dry-run
      
  2. CI/CD Integration:
    • Add to GitHub Actions (.github/workflows/lean-validation.yml):
      - name: Validate lean package
        run: composer validate-gitattributes
      
    • Fail the build on validation errors (default behavior).
  3. Gradual Enforcement:
    • Start with --keep-glob-pattern for critical files (e.g., storage/logs/).
    • Phase out exceptions over time.

Compatibility

  • Laravel Versions:
    • Explicitly supports Laravel 13+ (via badge), but works with older versions.
    • Note: New Laravel features (e.g., bootstrap/cache/) may need .lpv customizations.
  • PHP Versions:
    • Requires PHP 8.2+ (aligns with Laravel 10+).
    • Risk: Older Laravel apps (PHP 8.1) may need polyfills.
  • Git Compatibility:
    • Relies on Git’s export-ignore; no conflicts with other Git tools (e.g., git-lfs).

Sequencing

  1. Pre-Release:
    • Run composer validate-gitattributes in post-release scripts to catch issues before publishing.
  2. CI Pipeline:
    • Place validation early (e.g., after composer install) to fail fast.
    • Example order:
      composer install
      composer validate-gitattributes
      phpunit
      
  3. Post-Merge (Optional):
    • Use GitHub Actions to validate PRs (non-blocking) with --report-stale-export-ignores.

Operational Impact

Maintenance

  • Low Overhead:
    • Automated: Once configured, validation runs with Composer/Git commands.
    • Presets: Reduce manual updates for Laravel-specific paths.
  • Customization:
    • .lpv Files: Store project-specific patterns in version control.
    • CLI Flags: Override defaults (e.g., --keep-glob-pattern '{storage/logs/}') without modifying code.
  • Dependency Updates:
    • Monitor for Laravel-specific changes (e.g., new dev directories).
    • Action: Extend .lpv files or update presets.

Support

  • Troubleshooting:
    • Common Issues:
      • False positives from custom .gitattributes (use --diff to debug).
      • Performance in large repos (optimize --validate-git-archive or skip in CI).
    • Debugging Tools:
      • --dry-run for previewing changes.
      • --tree to inspect source/dist structures.
  • Documentation:
    • Internal Runbooks:
      • Example: "How to exclude storage/framework/ from validation."
    • Team Training:
      • 1-hour workshop on .gitattributes, .lpv files, and Composer scripts.

Scaling

  • Performance:
    • Large Repos:
      • Cache --validate-git-archive results or run in parallel with other checks.
      • Optimization: Exclude known-clean directories (e.g., vendor/) from validation.
    • Distributed Teams:
      • Use GitHub Actions to validate across all branches (non-blocking for feature branches).
  • Multi-Repo:
    • Monorepos: Centralize .lpv files or use directory-specific configs.
    • Multi-Package: Validate each package independently in CI.

Failure Modes

Failure Scenario Impact Mitigation
Missing .gitattributes Build fails in CI. Use --create or automate .gitattributes generation.
Stale export-ignore rules Dev artifacts leak into releases. Run --report-stale-export-ignores regularly.
Overly strict validation Blocks legitimate files. Use --keep-glob-pattern or adjust presets.
CI timeout due to --validate-git-archive Flaky builds. Cache results or skip in non-critical pipelines.
Custom .gitattributes conflicts Validation fails. Merge rules manually or use --overwrite cautiously.

Ramp-Up

  • Onboarding:
    • Step 1: Add to composer.json and run locally.
    • Step 2: Integrate into CI with --dry-run.
    • Step 3: Gradually enforce
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai