artemyurov/moonshine-command-schedule-job

Single entry point for Laravel scheduled commands and queued jobs with MoonShine admin UI

Maintainers

Package info

github.com/ArtemYurov/moonshine-command-schedule-job

pkg:composer/artemyurov/moonshine-command-schedule-job

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-03-23 20:21 UTC

This package is auto-updated.

Last update: 2026-03-23 20:21:20 UTC


README

PHP Laravel MoonShine License

One class = artisan command + scheduler + queue job + admin UI.

Define a single service class — the package auto-registers an artisan command and scheduler entry, with a MoonShine admin panel for managing schedules at runtime.

Quick Start

class SyncAccountData extends CommandScheduleJobService
{
    protected string $commandSignature = 'sync:account-data {--account-id=}';
    protected string $commandDescription = 'Sync account data from external API';
    protected ?string $scheduleFrequency = 'everyFiveMinutes';
    protected ?string $jobClass = SyncAccountDataJob::class;

    protected function handle(array $params = []): void
    {
        $account = Account::findOrFail($params['account-id']);
        $this->dispatchJob($account);
    }
}
php artisan sync:account-data --account-id=42

Installation

composer require artemyurov/moonshine-command-schedule-job
php artisan migrate

Publish config (optional):

php artisan vendor:publish --tag=command-schedule-job-config

Features

  • Console + Scheduler — every service automatically becomes an artisan command and a scheduler entry
  • Queue Jobs — set $jobClass to dispatch queued jobs with built-in deduplication
  • MoonShine Admin UI — toggle scheduler, configure frequency, view run times, copy commands
  • Artisan Generatorphp artisan make:command-schedule-job-service MyService
  • Auto-discovery — scans configured directories for service classes

Service Discovery

The package auto-discovers services by scanning configured directories:

// config/command-schedule-job.php
'discovery' => [
    'paths' => ['app/Services/'],
    'namespaces' => ['App\\Services'],
],

Any non-abstract class extending CommandScheduleJobService found in these paths will be auto-registered.

Service Properties

Property Type Default Description
$commandSignature string required Artisan command signature
$commandDescription string required Command description
$scheduleFrequency ?string null Schedule method (daily, hourly, everyFiveMinutes, etc.)
$scheduleFrequencyArgs ?array null Arguments for the frequency method
$scheduleConsoleArgs ?string null Extra console arguments for the scheduled command
$jobClass ?string null Job class to dispatch (null = sync execution)
$withoutOverlappingJob bool true Check for active jobs before dispatch
$withoutOverlappingJobExpiresAt ?int null Lookup window in minutes (null = config default)

Configuration

// config/command-schedule-job.php
return [
    'discovery' => [
        'paths' => ['app/Services/'],
        'namespaces' => ['App\\Services'],
    ],
    'table' => 'command_schedule_jobs',
    'default_without_overlapping_job_expires_at' => 180,
];

Optional Dependencies

Package What it enables
laravel/horizon Queue-based job search and management
artemyurov/moonshine-db-joblog PID-based precise job termination
ext-posix PID-based process termination

Core functionality works without these. Job deduplication and termination are enhanced when installed.

Requirements

  • PHP 8.2+
  • Laravel 11 or 12
  • MoonShine 4.x

License

MIT