New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

havn/laravel-executable

Single-task action classes for Laravel. Fully queueable, with a testing API that makes you like writing tests more than the actual code.
7,550
Install
composer require havn/laravel-executable
Latest Version:v1.3.1
PHP:^8.3
Laravel:12 · 13
License:MIT
Last Updated:Jun 22, 2026
Links: GitHub  ·  Packagist
Maintainer: hxnk

Single-task action classes for Laravel.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Fully queueable, with a testing API that makes you like writing tests more than the actual code.

Read the full documentation at docs.havn.nl.

Installation

composer require havn/laravel-executable

Requirements: PHP 8.3+ | Laravel 12+

Quick Example

A plain PHP class with a trait and an execute() method:

use Havn\Executable\QueueableExecutable;

class ProcessPayment
{
    use QueueableExecutable;

    public function __construct(
        private PaymentGateway $gateway,
    ) {}

    public function execute(Payment $payment): void
    {
        $this->gateway->charge($payment);
        
        $payment->update(['status' => 'completed']);
    }
}

Four execution modes:

// Sync — runs immediately, returns the result
ProcessPayment::sync()->execute($payment);

// Queue — dispatches to the queue
ProcessPayment::onQueue()->execute($payment);

// Prepare — returns a job without dispatching (for chains and batches)
$job = ProcessPayment::prepare()->execute($payment);

// Test — runs the real code in a testable context
ProcessPayment::test()->execute($payment);

Queue configuration at dispatch time:

ProcessPayment::onQueue('high-priority')
    ->delay(60)
    ->tries(3)
    ->execute($payment);

Testing

Mock, spy, or assert. All built in:

// Mock
ProcessPayment::mock()
    ->shouldExecute()
    ->with($payment)
    ->once();

// Spy
ProcessPayment::spy();
ProcessPayment::sync()->execute($payment);
ProcessPayment::assert()->executed()->with($payment);

// Queue assertions
Queue::fake();
ProcessPayment::onQueue()->execute($payment);
ProcessPayment::assert()->queued()->on('high-priority')->with($payment)->once();

Contributing

Contributions are welcome. Please see CONTRIBUTING for details.

Security

Please review our security policy for reporting security vulnerabilities.

License

The MIT License (MIT). See License File for details.

Credits


Made with care by Havn

Related Packages

salopot/laravel-queue-walker

Laravel queue walker, process all jobs on a queue.

531 2
aryeo/monitored-jobs

Monitor for your Laravel jobs.

30,054 14
mateffy/laravel-job-progress

Track and show progress of your background jobs (for progress bar UIs etc.)

5,253 45
deivide/laravel-failed-jobs

UI for Laravel failed jobs with retry support. Fork of hpwebdeveloper/laravel-fa...

1,329 0

Version History

Version Released PHP Laravel License
v1.3.1 ^8.3 ^12.0|^13.0 MIT
v1.3.0 ^8.3 ^12.0|^13.0 MIT
v1.2.1 ^8.3 ^12.0|^13.0 MIT
v1.2.0 ^8.3 ^12.0|^13.0 MIT
v1.1.0 ^8.3 ^12.0|^13.0 MIT