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

Technical Evaluation

Architecture Fit

  • Lean Package Philosophy: Aligns perfectly with Laravel/PHP package optimization by enforcing exclusion of non-essential files (e.g., .github/, .idea/, vendor/) from release artifacts. Reduces bloated distributions and improves maintainability.
  • Git Integration: Leverages .gitattributes (native Git feature) for exclusion rules, avoiding custom build steps or post-processing. Complements Laravel’s existing Git workflows.
  • Preset Support: Predefined patterns for PHP (default), Python, Rust, etc., reduce configuration overhead for Laravel projects. Custom patterns can extend support for Laravel-specific directories (e.g., storage/logs/, bootstrap/cache/).

Integration Feasibility

  • Composer Integration: Seamless via composer.json scripts (e.g., post-release hooks) or CI/CD pipelines. Example:
    "scripts": {
      "post-release": "lean-package-validator validate --validate-git-archive"
    }
    
  • CI/CD Compatibility: Works with GitHub Actions, GitLab CI, or Laravel Forge via CLI or GitHub Action. Low risk of breaking existing pipelines.
  • Laravel-Specific Use Cases:
    • Artisan Commands: Could wrap lpv in a custom Artisan command for devs (e.g., php artisan validate:gitattributes).
    • Deploy Hooks: Validate .gitattributes before deploying to production to prevent accidental inclusion of sensitive files (e.g., storage/).

Technical Risk

  • False Positives/Negatives:
    • Risk of over-aggressive exclusions (e.g., excluding config/ which may contain critical runtime files). Mitigate via --keep-glob-pattern or custom .lpv files.
    • Validation Lag: --validate-git-archive creates temporary archives, which may slow down CI pipelines for large repos. Test performance with Laravel’s monorepo-like structures (e.g., vendor/).
  • Dependency Conflicts:
    • Minimal PHP 8.2+ requirement may conflict with legacy Laravel 8.x projects. Use --preset=PHP to align with Laravel’s conventions.
  • Tooling Maturity:
    • Low stars (17) and dependents (0) suggest niche adoption. Validate stability with Laravel’s release cadence (e.g., test against Laravel 11+).

Key Questions

  1. Laravel-Specific Exclusions:
    • Should Laravel-specific directories (e.g., storage/, bootstrap/cache/) be pre-configured in the PHP preset? If so, propose a PR to the package.
  2. CI/CD Impact:
    • How will --validate-git-archive perform in CI for Laravel projects with large vendor/ or node_modules/? Benchmark with a sample repo.
  3. Agentic Integration:
    • Can the --agentic-run JSON output be parsed by Laravel’s Horizon or Nova for automated remediation (e.g., auto-fixing .gitattributes)?
  4. Alternatives:
    • Compare with existing tools like git-archive-all or Laravel’s composer.json "extra": "exclude-from-classmap" for overlap.

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Primary Use Case: Enforce lean releases for Laravel packages (e.g., laravel/framework, custom packages). Reduces distribution size and improves Composer install times.
    • Secondary Use Case: Validate .gitattributes in monorepos (e.g., laravel/valet, laravel/sail) to exclude dev-specific files.
  • Tooling Synergy:
    • Composer: Integrate via composer.json scripts or composer validate-gitattributes command.
    • GitHub Actions: Use the dedicated action in PR checks or release workflows.
    • Artisan: Create a custom command (e.g., GitAttributesValidator) to surface lpv functionality to Laravel devs.

Migration Path

  1. Pilot Phase:
    • Step 1: Install locally in a Laravel package:
      composer require --dev stolt/lean-package-validator
      
    • Step 2: Add to composer.json:
      "scripts": {
        "validate-gitattributes": "lean-package-validator validate --preset=PHP"
      }
      
    • Step 3: Run manually during development:
      composer validate-gitattributes
      
  2. CI/CD Integration:
    • Add to GitHub Actions (example):
      - name: Validate Git Attributes
        run: composer validate-gitattributes -- --validate-git-archive
      
  3. Enforcement:
    • Fail CI if validation fails (e.g., --validate-git-archive catches leaks).
    • Use --keep-glob-pattern '{storage/logs/,bootstrap/cache/}' to whitelist Laravel-specific files.

Compatibility

  • Laravel Versions:
    • Supported: Laravel 10+ (PHP 8.2+). For Laravel 9.x, use PHP 8.1-compatible fork or polyfills.
    • Legacy: Not recommended for Laravel <9 due to PHP version constraints.
  • Existing Workflows:
    • No Breaking Changes: Operates on .gitattributes, which is independent of Laravel’s build tools.
    • Composer Scripts: Safe to add alongside existing scripts (e.g., post-autoload-dump).
  • Customization:
    • Override PHP preset via .lpv file or --glob-pattern:
      lean-package-validator validate --glob-pattern '{*.php,config/,storage/logs/,vendor/}'
      

Sequencing

  1. Pre-Release:
    • Run composer validate-gitattributes --validate-git-archive to catch leaks before tagging.
  2. Post-Release:
    • Use in CI to gate PRs that modify .gitattributes or add excluded files.
  3. Development:
    • Add to pre-commit hooks (via husky or Laravel Forge) to catch issues early.

Operational Impact

Maintenance

  • Low Overhead:
    • No runtime dependencies; runs as a CLI tool. Updates via Composer (composer update stolt/lean-package-validator).
  • Configuration Drift:
    • Risk of .gitattributes diverging from expected patterns. Mitigate with:
      • Automated Updates: Use lean-package-validator update in CI to reconcile drift.
      • Documentation: Pin .lpv files to composer.json or README.md for reproducibility.
  • Deprecation Risk:
    • --create/--overwrite flags deprecated in v5.0. Migrate to create/update commands in Laravel projects.

Support

  • Troubleshooting:
    • Common Issues:
      • False positives for Laravel-specific files (e.g., storage/framework/). Solution: Use --keep-glob-pattern.
      • Permission errors in CI. Solution: Cache .gitattributes or use --dry-run for debugging.
    • Debugging Tools:
      • --diff and --report-stale-export-ignores for diagnosing mismatches.
      • --agentic-run for programmatic error handling.
  • Community:
    • Limited adoption; rely on GitHub issues or PHP/Packagist forums. Contribute Laravel-specific presets to the package.

Scaling

  • Performance:
    • Large Repos: --validate-git-archive may slow down CI. Optimize by:
      • Excluding vendor/ from validation (it’s already ignored by default).
      • Running in parallel with other checks (e.g., PHPStan).
    • Distributed Teams: Enforce via CI to prevent local overrides.
  • Multi-Package Repos:
    • Use --glob-pattern-file to define per-package rules in a monorepo (e.g., packages/package-a/.lpv).

Failure Modes

Failure Scenario Impact Mitigation
.gitattributes missing CI fails or releases include dev files. Use --create or init in CI setup.
Stale export-ignore entries Non-existent files still ignored. Use --report-stale-export-ignores in CI.
--validate-git-archive timeout CI job fails due to large repo. Exclude vendor/ or run in a subdirectory.
Custom .lpv file conflicts Manual changes override presets. Use refresh command to merge updates.
PHP version mismatch Tool fails on Laravel 9.x. Pin to PHP 8.1 or use a fork.

Ramp-Up

  • Onboarding:
    • For Developers:
      • Add to composer.json and run composer validate-gitattributes locally.
      • Document Laravel-specific exclus
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
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
twbs/bootstrap4