PHPackages                             vuthaihoc/moox-jobs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. vuthaihoc/moox-jobs

ActiveLibrary[Caching](/categories/caching)

vuthaihoc/moox-jobs
===================

Manage Job Queues, Failed Jobs and Batches in Filament.

v4.0.3(8mo ago)0553[1 PRs](https://github.com/vuthaihoc/moox-jobs/pulls)MITPHP

Since Sep 4Pushed 8mo agoCompare

[ Source](https://github.com/vuthaihoc/moox-jobs)[ Packagist](https://packagist.org/packages/vuthaihoc/moox-jobs)[ Docs](https://github.com/mooxphp/jobs)[ GitHub Sponsors](https://github.com/mooxphp)[ RSS](/packages/vuthaihoc-moox-jobs/feed)WikiDiscussions crdb Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (0)

[![Moox Jobs](https://github.com/mooxphp/moox/raw/main/art/banner/jobs.jpg)](https://github.com/mooxphp/moox/raw/main/art/banner/jobs.jpg)

Moox Jobs
=========

[](#moox-jobs)

Managing Job Queues, Failed Jobs and Batches in Filament.

Alternative to Laravel Horizon, if you use the database driver for queues. Nice addon to Laravel Horizon, if you use Redis. See [Limitations](#limitations) below for more information about Redis, Amazon SQS and Beanstalkd compatibility. More information about Laravel Job Queues and how Moox Jobs works in our [Jobs for Beginners Guide](#jobs-for-beginners).

Requirements
------------

[](#requirements)

Moox Jobs requires

- [PHP 8.1](https://www.php.net/) or higher
- [Laravel 10](https://laravel.com/docs/installation) or higher
- [Filament 3](https://filamentphp.com/docs/panels/installation) or higher

in short

```
composer create-project laravel/laravel moox-jobs-demo
composer require filament/filament
php artisan filament:install --panels
php artisan make:filament-user
```

Upgrading from Moox Jobs V2
---------------------------

[](#upgrading-from-moox-jobs-v2)

Moox Jobs V3 requires changes to the database schema. We made an convenient update command for you:

```
composer update
php artisan mooxjobs:update
```

The update command takes care about changing and creating the new fields without loosing data. Alternatively you may delete the job-manager table and simply run the following install command.

Quick installation
------------------

[](#quick-installation)

These two commmands are all you need to install the package:

```
composer require moox/jobs
php artisan mooxjobs:install
```

Curious what the install command does? See [manual installation](#manual-installation) below.

Features
--------

[](#features)

### Jobs

[](#jobs)

Monitor your running and finished jobs.

[![screenshot-jobs](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-jobs.jpg)](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-jobs.jpg)

### Jobs waiting

[](#jobs-waiting)

See all waiting Jobs queued, delete one, many or even all waiting jobs at once before they hit the queue. And, yes we do not only have dark mode.

[![screenshot-waiting](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-waiting.jpg)](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-waiting.jpg)

### Jobs failed

[](#jobs-failed)

See all failed Jobs including details, retry or delete single jobs, many jobs or even all failed jobs at once.

[![screenshot-details](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-details.jpg)](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-details.jpg)

[![screenshot-detail](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-detail.jpg)](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-detail.jpg)

### Job batches

[](#job-batches)

Monitor your job batches, prune batches.

[![screenshot-batches](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-batches.jpg)](https://github.com/mooxphp/moox/raw/main/art/screenshot/jobs-batches.jpg)

Configuration
-------------

[](#configuration)

The configuration of the package is work in progress. To make it better suitable for integrators, we will add more flexibility and better translations soon.

New in 3.1 is the switch to Google Icons and the ability to [switch back to Heroicons in Moox Core](https://github.com/mooxphp/core#disable-google-icons).

If there is something you need to be configurable, drop us an issue.

Manual Installation
-------------------

[](#manual-installation)

This Laravel package is made for FilamentPHP and the awesome TALL-Stack. If you don't want to use our install command, follow thes manual steps to install the package.

Install the package via Composer:

```
composer require moox/jobs
```

Create the necessary tables:

```
php artisan vendor:publish --tag="jobs-manager-migration"
php artisan vendor:publish --tag="jobs-batch-migration"
php artisan vendor:publish --tag="jobs-queue-migration"
php artisan vendor:publish --tag="jobs-manager-foreigns-migration"

# Queue tables, if using the database driver
# Not required for Redis, Amazon SQS or Beanstalkd
php artisan queue:table
php artisan queue:failed-table
php artisan queue:batches-table

php artisan migrate
```

Publish the config file with:

```
php artisan vendor:publish --tag="jobs-config"
```

This is the content of the published config file:

```
return [
    'resources' => [
        'jobs' => [
            'enabled' => true,
            'label' => 'Job',
            'plural_label' => 'Jobs',
            'navigation_group' => 'Job manager',
            'navigation_icon' => 'heroicon-o-play',
            'navigation_sort' => 1,
            'navigation_count_badge' => true,
            'resource' => Moox\Jobs\Resources\JobsResource::class,
        ],
        'jobs_waiting' => [
            'enabled' => true,
            'label' => 'Job waiting',
            'plural_label' => 'Jobs waiting',
            'navigation_group' => 'Job manager',
            'navigation_icon' => 'heroicon-o-pause',
            'navigation_sort' => 2,
            'navigation_count_badge' => true,
            'resource' => Moox\Jobs\Resources\JobsWaitingResource::class,
        ],
        'failed_jobs' => [
            'enabled' => true,
            'label' => 'Failed Job',
            'plural_label' => 'Failed Jobs',
            'navigation_group' => 'Job manager',
            'navigation_icon' => 'heroicon-o-exclamation-triangle',
            'navigation_count_badge' => true,
            'resource' => Moox\Jobs\Resources\JobsFailedResource::class,
        ],
        'job_batches' => [
            'enabled' => true,
            'label' => 'Job Batch',
            'plural_label' => 'Job Batches',
            'navigation_group' => 'Job manager',
            'navigation_icon' => 'heroicon-o-inbox-stack',
            'navigation_sort' => 4,
            'navigation_count_badge' => true,
            'resource' => Moox\Jobs\Resources\JobBatchesResource::class,
        ],
    ],
    'pruning' => [
        'enabled' => true,
        'retention_days' => 7,
    ],
];
```

Register the Plugins in `app/Providers/Filament/AdminPanelProvider.php`:

```
->plugins([
    \Moox\Jobs\JobsPlugin::make(),
    \Moox\Jobs\JobsWaitingPlugin::make(),
    \Moox\Jobs\JobsFailedPlugin::make(),
    \Moox\Jobs\JobsBatchesPlugin::make(),
])
```

Instead of publishing and modifying the config-file, you can also do all settings in AdminPanelProvider like so:

```
->plugins([
	\Moox\Jobs\JobsPlugin::make()
	    ->label('Job runs')
	    ->pluralLabel('Jobs that seems to run')
	    ->enableNavigation(true)
	    ->navigationIcon('heroicon-o-face-smile')
	    ->navigationGroup('My Jobs and Queues')
	    ->navigationSort(5)
	    ->navigationCountBadge(true)
	    ->enablePruning(true)
	    ->pruningRetention(7),
	\Moox\Jobs\JobsWaitingPlugin::make()
	    ->label('Job waiting')
	    ->pluralLabel('Jobs waiting in line')
	    ->enableNavigation(true)
	    ->navigationIcon('heroicon-o-calendar')
	    ->navigationGroup('My Jobs and Queues')
	    ->navigationSort(5)
	    ->navigationCountBadge(true)
	\Moox\Jobs\JobsFailedPlugin::make()
	    ->label('Job failed')
	    ->pluralLabel('Jobs that failed hard')
	    ->enableNavigation(true)
	    ->navigationIcon('heroicon-o-face-frown')
	    ->navigationGroup('My Jobs and Queues')
	    ->navigationSort(5)
	    ->navigationCountBadge(true)
])
```

You don't need to register all Resources. If you don't use Job Batches, you can hide this feature by not registering it.

Jobs for Beginners
------------------

[](#jobs-for-beginners)

Job queues are very useful. Every task that needs more than a couple of seconds can be handled in the background and Moox Jobs gives you full control in your applications UI. But starting with Laravel Job Queues needs some preparation.

The first decision depends on your hosting and deployment:

### Laravel Forge

[](#laravel-forge)

Laravel Forge supports Redis, Horizon and Supervisor. The best way is to install Horizon and to enable it in the Forge UI. You can then schedule any job (or command dispatching your job).

To schedule any command without the need to change code (in kernel.php), you might consider using the [Filament Database Schedule plugin](https://filamentphp.com/plugins/husam-tariq-database-schedule).

More information:

- [Laravel Forge docs: Queues](https://forge.laravel.com/docs/sites/queues.html)

### Shared Hosting

[](#shared-hosting)

On most Shared Hosting and Managed Servers Redis and Supervisor are not available. The good thing: using Moox Jobs on shared hosts will perfectly work. Using the database queue-driver, you will be able to monitor and control your jobs and batches without pain.

You need SSH access to start the queue worker like this:

```
php artisan queue:work
```

and the Laravel Scheduler like this:

```
php artisan schedule:work
```

The best way, to automate your jobs (and care for re-running the queue:worker after failure), is to create a crontab to run the Laravel Scheduler minutely and to use the [Filament Database Schedule plugin](https://filamentphp.com/plugins/husam-tariq-database-schedule) to run your jobs (or commands).

More information:

- [Laravel Queues for Beginners](https://sagardhiman021.medium.com/demystifying-queues-and-jobs-in-laravel-a-beginners-guide-with-examples-in-2023-a8e52698a298)
- [Using Laravel Queues on Shared Hosting](https://talltips.novate.co.uk/laravel/using-queues-on-shared-hosting-with-laravel)

### Shared Hosting API

[](#shared-hosting-api)

The Shared Hosting API in Moox Core allows to `schedule/run` from an URL. And in Moox Jobs we use this feature to do a `queue:work` from an URL.

-

You can add an optional `timeout` parameter to the URL to specify the timeout for the queue worker in seconds. If no timeout is specified, the default timeout of 60 seconds is used.

- [https://yourdomain.com/queue/work?token=secure&amp;timeout=300](https://yourdomain.com/queue/work?token=secure&timeout=300)

If you want to use the Shared Hosting API, you need to set the `SHARED_HOSTING_ENABLED` in [Core Config](https://github.com/mooxphp/core/blob/main/README.md#Shared-Hosting) to `true` and the `SHARED_HOSTING_TOKEN` config to a secure token.

### Root Server

[](#root-server)

On a Root Server, VPS or Cloud Server Droplet the fastest way is to do job queuing like shared hosting. But as the combination Redis with Supervisor is much more stable and minimum twice as fast, you may also consider installing Redis and Supervisor manually using root privileges or (depending on your provider and deployment, maybe Forge, Envoyer or Ploi.io) a more convenient UI.

More information:

- [Laravel Horizon on Ubuntu](https://dev.to/shuv1824/laravel-horizon-with-nginx-and-ubuntu-18-04-on-digitalocean-1fod)

### Laravel Vapor

[](#laravel-vapor)

On Laravel Vapor, the first-party deployment tool for going Serverless (using Amazon AWS Lambda Services), Laravel will automatically use Amazon SQS (Simple Queue Services) as queue driver. Laravel SQS is partly supported by Moox Jobs, means you can monitor jobs and failed jobs, retry failed jobs and use the progress feature. Pending jobs and batches are currently not implemented.

More information:

- [Laravel Vapor Docs: Queues](https://docs.vapor.build/resources/queues.html)

When you got your job queues up and running, a good way to test Moox Jobs is using our

### Demo Job

[](#demo-job)

You do not need to change anything in your Jobs to work with Filament Job Monitor. But especially for long running jobs you may find this example interesting:

```
