定制 auguzsto/job 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

auguzsto/job

最新稳定版本:1.0.8

Composer 安装命令:

composer require auguzsto/job

包简介

A simple and elegant tool for running background processes without the need for external libraries.

README 文档

README

A job executes a method in the background. If there are too many jobs for too few workers, there will be competition. When a worker is free, the job will dispatch the task to that free worker.

A PID is created for each registered worker. The worker checks for tasks to be performed. In other words, worker = PID.

By default, the worker limit is 10.

Requirements

  • PHP >= 8.3
  • Linux

Install

composer require auguzsto/job

Simple example

Simulating a very time-consuming request.

<?php
namespace Auguzsto\Job\Tests;

    class Request 
    {

        public static function slow(): void 
        {
            sleep(60);
        }

        public static function slowBy(int $seconds): void 
        {
            sleep($seconds);
        }
    }

Run this method in the background with the job.

<?php
require_once __DIR__ . "/../vendor/autoload.php";

use Auguzsto\Job\Job;
use Auguzsto\Job\Tests\Request;

    $job = new Job(Request::class, "slow");
    $job->execute();

With args.

<?php
require_once __DIR__ . "/../vendor/autoload.php";

use Auguzsto\Job\Job;
use Auguzsto\Job\Tests\Request;

    $job = new Job(Request::class, "slowBy", [35]);
    $worker = $job->execute();
    echo $worker;

Execute by include injection.

<?php
require_once __DIR__ . "/../vendor/autoload.php";

use Auguzsto\Job\Job;

    $job = new Job("Request", "slowBy", [35]);
    $job->include(__DIR__ . "/Tests/Request.php");
    $worker = $job->execute();
    echo $worker;

When the job sends a task to the worker, the id of this worker is returned.

See logs erros

You can read logs error in

  • /tmp/php-job-error.log

Example

cat /tmp/php-job-error.log

统计信息

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

GitHub 信息

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

其他信息

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