florianpalabost / lara-stubs
Opinionated Laravel stubs with strict types, final classes, and modern PHP conventions
v0.1.0
2025-12-20 14:20 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0
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
finalkeyword 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 modifierdata.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