Search by

concept-image / laravel-stubs

concept-image

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.

Package info

gitlab.com/concept-image-public/laravel-stubs

Issues

pkg:composer/concept-image/laravel-stubs

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

1.0.0 2026-11-12 10:21 UTC

This package is not auto-updated.

Last update: 2026-11-12 12:41:01 UTC


README

Latest Version on Packagist License

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

CommandNamespaceSuffixOptions
make:actionApp\ActionsAction--model, --force
make:serviceApp\ServicesService--force
make:helperApp\HelpersHelper--force
make:facadeApp\Support\Facadesnone--accessor, --force
make:value-objectApp\ValueObjectsnone--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 CreateUser and make:action CreateUserAction both create CreateUserAction.
  • A trailing .php is 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 --force is 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:

StubPlaceholders
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