concept-image / laravel-stubs
Laravel Stubs: Artisan generators for action, service, helper, facade and value object classes that Laravel does not ship natively. Install it as a dev dependency.
Requires
- php: ^8.3
- illuminate/console: ^12.0|^13.0
- illuminate/filesystem: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-arch: ^4.0|^5.0
Suggests
- This package should be installed as a dev dependency: composer require --dev concept-image/laravel-stubs
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-12 12:41:01 UTC
README
Artisan generators for the PHP classes Laravel does not scaffold natively: actions, services, helpers, facades and value objects. Every generated file uses declare(strict_types=1) and a final (or final readonly) class.
Sister package of WP Acorn Stubs for Laravel applications.
Requirements
- PHP 8.3 or higher
- Laravel 12 or 13
Installation
Install it as a development dependency:
composer require --dev concept-image/laravel-stubs
The service provider is registered through Laravel package discovery.
Available commands
| Command | Namespace | Suffix | Options |
|---|---|---|---|
make:action | App\Actions | Action | --model, --force |
make:service | App\Services | Service | --force |
make:helper | App\Helpers | Helper | --force |
make:facade | App\Support\Facades | none | --accessor, --force |
make:value-object | App\ValueObjects | none | --force |
Use the native commands for the rest: make:enum (--string / --int), make:trait, make:interface, make:class.
Naming
- The suffix is appended once:
make:action CreateUserandmake:action CreateUserActionboth createCreateUserAction. - A trailing
.phpis ignored and each segment is StudlyCased (make:helper string→StringHelper). /and.create sub-namespaces:make:action Billing.ChargeCard→App\Actions\Billing\ChargeCardAction.- An existing file is never overwritten (the command exits with code 1) unless
--forceis given.
Action
php artisan make:action PlaceOrder --model=Order
<?php
declare(strict_types=1);
namespace App\Actions;
use App\Models\Order;
final readonly class PlaceOrderAction
{
/**
* Execute the action.
*/
public function handle(Order $order): void
{
//
}
}
Without --model, handle() takes no parameter.
Service
php artisan make:service Payment # App\Services\PaymentService
A final readonly class with an empty constructor, ready for constructor-injected dependencies.
Helper
php artisan make:helper String # App\Helpers\StringHelper
A final class with a private constructor: helpers only expose static methods.
Facade
php artisan make:facade PaymentGateway # accessor 'payment_gateway'
php artisan make:facade Payment --accessor=payments.gateway # accessor 'payments.gateway'
php artisan make:facade Payment --accessor="App\Services\PaymentService" # accessor PaymentService::class
By default the accessor is the snake_cased class name. A class given to --accessor is imported, returned as ::class and linked with an @see tag for IDEs.
Value object
php artisan make:value-object EmailAddress # App\ValueObjects\EmailAddress
final readonly class EmailAddress
{
public function __construct(
public string $value,
) {
//
}
public function equals(self $other): bool
{
return $this->value === $other->value;
}
}
Customising the stubs
php artisan vendor:publish --tag=laravel-stubs
Stubs are copied to stubs/ at the root of your application. A stub there takes precedence over the package's, as with Laravel's own stub:publish. Available placeholders:
| Stub | Placeholders |
|---|---|
| all | {{ namespace }}, {{ class }} |
action.stub | {{ imports }}, {{ parameters }} |
facade.stub | {{ imports }}, {{ docblock }}, {{ accessor }} |
Empty placeholders leave no extra blank lines; use statements are sorted.
Development
composer install
composer test # Pest
composer analyse # PHPStan / Larastan, level max
composer lint # Pint
composer ci # Pint --test, PHPStan and Pest
vendor/bin/testbench make:action Demo # try a command against the Testbench skeleton
License
This package is open-sourced software licensed under the MIT license.
Credits
- Author: Aurélien Cellier
- Inspired by: nunomaduro/essentials
make:action