aaronfrancis/enqueue 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

aaronfrancis/enqueue

最新稳定版本:v0.1.0

Composer 安装命令:

composer require aaronfrancis/enqueue

包简介

Declarative job enqueueing with schedule-aware dispatch for Laravel

README 文档

README

Latest Version on Packagist Tests Total Downloads PHP Version License

Declarative job enqueueing with schedule-aware dispatch for Laravel.

Jobs often need to dispatch themselves on a schedule—syncing data every hour, processing uploads every few minutes, sending reports on weekdays. Normally this means scattering scheduling logic across routes/console.php while the job sits elsewhere, or writing awkward wrapper commands.

Enqueue lets the job own its entire lifecycle. Each job declares how to enqueue itself (maybe one instance per warehouse, or one per pending upload) and optionally when (hourly, weekdays, or custom logic). Run jobs:enqueue every minute and each job takes care of the rest.

Installation

composer require aaronfrancis/enqueue

Usage

Implement the Enqueueable interface on any job:

<?php

namespace App\Jobs;

use AaronFrancis\Enqueue\Contracts\Enqueueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;

class SyncInventory implements ShouldQueue, Enqueueable
{
    use Queueable;

    public function __construct(public int $warehouseId) {}

    public function handle(): void
    {
        // Sync inventory for this warehouse...
    }

    public static function enqueue(): void
    {
        Warehouse::all()->each(function ($warehouse) {
            dispatch(new static($warehouse->id));
        });
    }
}

Schedule the command to run every minute:

// routes/console.php
Schedule::command('jobs:enqueue')->everyMinute();

Controlling When Jobs Enqueue

Add a shouldEnqueue() method to control timing:

use Illuminate\Console\Scheduling\CallbackEvent;

public static function shouldEnqueue(CallbackEvent $event): CallbackEvent
{
    return $event->hourly()->weekdays();
}

Or return a boolean for custom logic:

public static function shouldEnqueue(CallbackEvent $event): bool
{
    return Cache::get('sync_enabled', true);
}

Preview Mode

See what would be enqueued without dispatching:

php artisan jobs:enqueue --pretend

Requirements

  • PHP 8.2+
  • Laravel 10, 11, or 12.24+

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固