承接 j-sandaruwan/laravel-job-monitor 相关项目开发

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

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

j-sandaruwan/laravel-job-monitor

Composer 安装命令:

composer require j-sandaruwan/laravel-job-monitor

包简介

Laravel package for tracking queue jobs with status, progress, and detailed execution history

README 文档

README

Latest Version on Packagist Total Downloads

A lightweight Laravel package for tracking queue jobs with status, progress, execution history, and detailed error logging.

Features

Automatic Job Tracking - Zero configuration needed, works out of the box
Real-Time Progress - Track job progress (0-100%) with simple trait
Detailed History - Status, attempts, errors, start/finish times
REST API - Pre-built endpoints for job listing, stats, and retry
Retry Failed Jobs - One-click retry functionality
Configurable - Flexible options for tracking, retention, and routes
Zero Dependencies - No external monitoring services required

Installation

Install the package via Composer:

composer require j-sandaruwan/laravel-job-monitor

Publish Configuration & Migrations

php artisan vendor:publish --provider="JSandaruwan\LaravelJobMonitor\JobMonitorServiceProvider"

This publishes:

  • config/job-monitor.php - Configuration file
  • Migration: create_job_histories_table.php

Run Migrations

php artisan migrate

Usage

Basic Tracking (Automatic)

All queue jobs are automatically tracked with no code changes needed! The package listens to Laravel's queue events and tracks:

  • Job start/finish times
  • Status (pending → processing → completed/failed)
  • Attempt count
  • Errors (if failed)
  • Progress (0% → 100%)

Progress Tracking (Manual)

To track job progress, add the TracksJobProgress trait to your job:

use JSandaruwan\LaravelJobMonitor\Traits\TracksJobProgress;
use Illuminate\Contracts\Queue\ShouldQueue;

class ProcessVideoJob implements ShouldQueue
{
    use TracksJobProgress;

    public function handle()
    {
        $this->updateProgress(10);  // 10% complete

        // Download video
        $this->updateProgress(30);

        // Process video
        $this->updateProgress(70);

        // Upload result
        $this->updateProgress(90);

        // Job completes → auto-set to 100%
    }
}

Alternative Method: Use queueProgress() for backward compatibility

$this->queueProgress(50);  // Same as updateProgress(50)

API Endpoints

The package provides REST API endpoints for accessing job data:

List All Jobs

GET /api/job-monitor/jobs?status=failed&per_page=50

Query Parameters:

  • search - Search by job ID, class name, or error message
  • status - Filter by status (pending, processing, completed, failed)
  • queue - Filter by queue name
  • job_type - Filter by job class name
  • date_from - Filter jobs after this date
  • date_to - Filter jobs before this date
  • per_page - Items per page (default: 25)

Get Single Job

GET /api/job-monitor/jobs/{id}

Get Statistics

GET /api/job-monitor/jobs/stats

Response:

{
    "total_jobs": 1534,
    "pending_jobs": 12,
    "completed_jobs": 1480,
    "failed_jobs": 42,
    "total_runtime": 45230,
    "average_runtime": 29.5
}

Retry Failed Job

POST /api/job-monitor/jobs/{id}/retry

Configuration

Edit config/job-monitor.php:

return [
    // Database table name
    'table_name' => 'job_histories',

    // Enable/disable tracking
    'enabled' => true,

    // Track specific queues only (empty = all queues)
    'track_queues' => [],  // e.g., ['default', 'high-priority']

    // Skip specific job classes
    'skip_jobs' => [],  // e.g., ['App\Jobs\InternalJob']

    // Retention policy (days)
    'retention_days' => 30,  // null = keep forever

    // API routes configuration
    'route' => [
        'enabled' => true,
        'prefix' => 'api/job-monitor',
        'middleware' => ['api'],
    ],

    // Pagination
    'per_page' => 25,
];

Environment Variables

JOB_MONITOR_ENABLED=true
JOB_MONITOR_TABLE=job_histories
JOB_MONITOR_RETENTION_DAYS=30
JOB_MONITOR_ROUTES_ENABLED=true
JOB_MONITOR_ROUTE_PREFIX=api/job-monitor
JOB_MONITOR_PER_PAGE=25

Frontend Integration

Build your own UI using the provided API endpoints. Example with Vue.js:

<script setup>
import { ref, onMounted } from "vue";
import axios from "axios";

const jobs = ref([]);

const fetchJobs = async () => {
    const { data } = await axios.get("/api/job-monitor/jobs");
    jobs.value = data.data;
};

const retryJob = async (jobId) => {
    await axios.post(`/api/job-monitor/jobs/${jobId}/retry`);
    fetchJobs(); // Refresh list
};

onMounted(fetchJobs);
</script>

<template>
    <div v-for="job in jobs" :key="job.id">
        <h3>{{ job.job_class }}</h3>
        <p>Status: {{ job.status }}</p>
        <div v-if="job.status === 'processing'">
            Progress: {{ job.progress }}%
        </div>
        <button v-if="job.status === 'failed'" @click="retryJob(job.id)">
            Retry
        </button>
    </div>
</template>

Data Retention

Clean up old job records automatically:

// In app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
    $retentionDays = config('job-monitor.retention_days', 30);

    if ($retentionDays) {
        $schedule->command('db:table', [
            'table' => config('job-monitor.table_name'),
            '--where' => "created_at < DATE_SUB(NOW(), INTERVAL {$retentionDays} DAY)"
        ])->daily();
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for recent changes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security

If you discover any security-related issues, please email janithsandaruwan29@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

j-sandaruwan/laravel-job-monitor 适用场景与选型建议

j-sandaruwan/laravel-job-monitor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「monitoring」 「laravel」 「progress」 「jobs」 「tracking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 j-sandaruwan/laravel-job-monitor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 j-sandaruwan/laravel-job-monitor 我们能提供哪些服务?
定制开发 / 二次开发

基于 j-sandaruwan/laravel-job-monitor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-31