florianpalabost/lara-stubs

Opinionated Laravel stubs with strict types, final classes, and modern PHP conventions

Maintainers

Package info

github.com/florianPalabost/lara-stubs

pkg:composer/florianpalabost/lara-stubs

Statistics

Installs: 214

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2025-12-20 14:20 UTC

This package is auto-updated.

Last update: 2026-02-20 14:49:02 UTC


README

Opinionated Laravel stubs with strict types, final classes, and modern PHP conventions.

Features

  • Strict Types: All PHP files include declare(strict_types=1)
  • Final Classes: Uses final keyword for better immutability and intentional inheritance
  • Modern Conventions: Follows current PHP and Laravel best practices
  • Custom Stubs: Includes Action and Data stubs for common patterns
  • Pest Integration: Test stubs use it() syntax

Installation

Install via Composer:

composer require florianpalabost/lara-stubs --dev

Publish the stubs to your project:

php artisan vendor:publish --tag=lara-stubs

This will copy all stubs to your project's stubs/ directory, where Laravel will automatically use them.

Available Stubs

Custom Stubs

  • action.stub - Action pattern class with strict types and final modifier
  • data.stub - Spatie Laravel Data class

Enhanced Laravel Stubs

All standard Laravel stubs with improvements:

  • Controllers (API, invokable, nested, singleton variants)
  • Models, migrations, factories, seeders
  • Jobs, listeners, events
  • Policies, observers
  • Requests, resources, rules
  • Tests (Pest with it() syntax)
  • And more...

Usage

After publishing, all php artisan make:* commands will use these stubs:

# Creates an Action with strict types and final modifier
php artisan make:class CreateUserAction

# Creates a Data class extending Spatie\LaravelData\Data
php artisan make:class UserData

# Creates a controller with enhanced stub
php artisan make:controller UserController

# Creates a Pest test using it() syntax
php artisan make:test UserTest

Customization

After publishing, you can customize the stubs in your stubs/ directory. Your changes will be used instead of Laravel's defaults.

Requirements

  • PHP 8.2 or higher
  • Laravel 11.x or 12.x

License

MIT