承接 havn/laravel-executable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

havn/laravel-executable

Composer 安装命令:

composer require 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.

README 文档

README

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

统计信息

  • 总下载量: 3.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固