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

Laravel Stubs Laravel Package

spatie/laravel-stubs

Opinionated Laravel stub templates from Spatie. Publish customized stubs for migrations, controllers, and models: no down() in migrations, controllers don’t extend a base, no guarded attributes, more return types, fewer docblocks.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Opinionated Laravel Stubs: Aligns with modern Laravel best practices (e.g., minimalist migrations, type hints, no forced inheritance). Fits well in projects prioritizing clean, maintainable boilerplate over legacy patterns (e.g., BaseController, guarded attributes).
  • Customization Potential: Stubs are opinionated but can be overridden via stubs-path config or custom stubs, making it adaptable to team-specific conventions.
  • Laravel-Centric: Tightly coupled to Laravel’s ecosystem (e.g., Artisan commands, Blade templates). Not suitable for non-Laravel PHP projects.

Integration Feasibility

  • Low Friction: Single-composer install (spatie/laravel-stubs) with zero manual setup. Replaces default Laravel stubs via service provider.
  • Backward Compatibility: No breaking changes to Laravel core; stubs are opt-in. Existing projects can adopt incrementally.
  • Testing: CI/CD-verified (GitHub Actions) and Packagist-trusted (Spatie’s reputation). Minimal risk for basic adoption.

Technical Risk

  • Opinion Clash: Teams relying on BaseController, guarded attributes, or verbose docblocks may face resistance or require stub overrides.
  • Migration Overhead: Projects with existing stubs (e.g., custom down() methods) may need manual cleanup or stub replacements.
  • Laravel Version Lock: Package targets Laravel 10+ (per README). Older versions may require compatibility checks.

Key Questions

  1. Does the team’s Laravel version (10+) align with the package’s support?
  2. Are there existing stubs (e.g., custom migrations/controllers) that conflict with the package’s opinions?
  3. How will stub customization be handled (e.g., team-specific overrides vs. package defaults)?
  4. Does the team prioritize boilerplate reduction over legacy patterns (e.g., BaseController)?

Integration Approach

Stack Fit

  • Primary Use Case: Laravel projects (10+) using Artisan scaffolding (make:model, make:migration, etc.).
  • Secondary Use Case: Teams adopting modern Laravel conventions (e.g., no down() migrations, type hints).
  • Non-Fit: Non-Laravel PHP, legacy Laravel (<10), or projects with strict stub requirements (e.g., enterprise templates).

Migration Path

  1. Installation:
    composer require spatie/laravel-stubs
    
    • Package auto-registers via service provider.
  2. Validation:
    • Test stubs with php artisan make:model TestModel and verify output (e.g., no down() in migrations).
  3. Override Customization (if needed):
    • Publish stubs: php artisan vendor:publish --tag=laravel-stubs.
    • Modify stubs in resources/stubs/ and extend via config:
      'stubs-path' => resource_path('stubs'),
      
  4. Phased Rollout:
    • Start with non-critical scaffolding (e.g., models) before migrations/controllers.

Compatibility

  • Laravel 10+: Fully supported. Older versions may need polyfills or stub adjustments.
  • Custom Artisan Commands: If extending make: commands, ensure they respect the package’s stub paths.
  • CI/CD: No impact; stubs are runtime-only.

Sequencing

  1. Pre-requisite: Laravel 10+ project.
  2. Step 1: Install package and validate default stubs.
  3. Step 2: Customize stubs (if needed) via publishing.
  4. Step 3: Update team documentation/onboarding to reflect new conventions.
  5. Step 4: Deprecate legacy stubs (e.g., BaseController) in code reviews.

Operational Impact

Maintenance

  • Pros:
    • Reduced Boilerplate: Fewer down() methods, no forced inheritance.
    • Type Safety: Added return type hints improve IDE support.
    • Consistent Output: Enforces team-wide stub conventions.
  • Cons:
    • Stub Customization: Teams may need to maintain overrides (e.g., for enterprise patterns).
    • Documentation: Requires updating guides/tutorials referencing old stubs (e.g., BaseController).

Support

  • Low Effort: MIT-licensed with active maintenance (recent releases, CI tests).
  • Troubleshooting:
    • Conflicts with custom stubs: Check stubs-path config.
    • Laravel version issues: Verify compatibility matrix.
  • Community: Spatie’s packages have strong GitHub/GitLab support (issues resolved quickly).

Scaling

  • Performance: Zero runtime overhead; stubs are compile-time.
  • Team Adoption:
    • Small Teams: Easy to enforce via package defaults.
    • Large Teams: May require stub customization or training to adopt opinions.
  • Monorepos: Safe to adopt per-project (no global side effects).

Failure Modes

Risk Impact Mitigation
Stub conflicts Broken scaffolding Publish and override stubs early.
Laravel version mismatch Installation/compatibility errors Pin Laravel version in composer.json.
Team resistance Adoption failure Pilot with a subset of developers.
Custom stub dependencies Maintenance burden Document override strategy upfront.

Ramp-Up

  • Onboarding Time: <1 hour for basic installation; <4 hours for customization.
  • Key Actions:
    1. Install package and test scaffolding.
    2. Review generated stubs against team conventions.
    3. Publish/customize stubs if needed.
    4. Update CI templates (if using make: commands in workflows).
  • Training:
    • Highlight changes (e.g., "migrations no longer have down()").
    • Provide examples of custom stubs for edge cases.
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
milesj/emojibase
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