1. Go to this page and download the library: Download moox/jobs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
->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)
])
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Moox\Jobs\Traits\JobProgress;
class DemoJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, JobProgress, Queueable, SerializesModels;
public $tries;
public $timeout;
public $maxExceptions;
public $backoff;
public function __construct()
{
$this->tries = 10;
$this->timeout = 120;
$this->maxExceptions = 3;
$this->backoff = 240;
}
public function handle()
{
$count = 0;
$steps = 10;
$final = 100;
while ($count < $final) {
$this->setProgress($count);
$count = $count + $steps;
sleep(10);
}
}
}
use Illuminate\Support\Carbon;
...
public function displayName()
{
$now = Carbon::now();
return "Demo Job | Started: ".$now;
}
namespace App\Console\Commands;
use App\Jobs\DemoJob;
use Illuminate\Console\Command;
class DemoJobCommand extends Command
{
protected $signature = 'moox:demojob';
protected $description = 'Start the Moox Demo Job';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$this->info('Starting Moox Demo Job');
DemoJob::dispatch();
$this->info('Moox Demo Job finished');
}
}
use App\Policies\JobMonitorPolicy;
use Moox\Jobs\Models\FailedJob;
use Moox\Jobs\Models\JobBatch;
use Moox\Jobs\Models\JobMonitor;
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
JobManager::class => JobManagerPolicy::class,
FailedJob::class => FailedJobPolicy::class,
JobBatch::class => JobBatchPolicy::class,
];
}
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class FailedJobPolicy
{
use HandlesAuthorization;
public function viewAny(User $user): bool
{
return $user->can('manage_failed_jobs');
}
}
bash
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