Documentation

Scheduler
in package

Class Scheduler

Table of Contents

Properties

$healthEnabled  : bool
$historyPath  : string
$jobQueue  : JobQueue|null
$logger  : Logger|null
$maxWorkers  : int
$modernConfig  : array<string|int, mixed>
$queuePath  : string
$webhookEnabled  : bool
$webhookToken  : string|null
$workers  : array<string|int, mixed>
$config  : array<string|int, mixed>
$executed_jobs  : array<string|int, Job>
$failed_jobs  : array<string|int, Job>
$jobs  : array<string|int, Job>
$jobs_run  : array<string|int, Job>
$output_schedule  : array<string|int, mixed>
$saved_jobs  : array<string|int, Job>
$status_path  : string

Methods

__construct()  : mixed
Create new instance.
addCommand()  : Job
Queue a raw shell command.
addFunction()  : Job
Queues a PHP function execution.
clearJobs()  : $this
Remove all queued Jobs.
getActiveTriggers()  : array<string|int, mixed>
Get active trigger methods
getAllJobs()  : array<string|int, Job>
Get all jobs if they are disabled or not as one array
getCronCommand()  : string
Helper to get the full Cron command
getHealthStatus()  : array<string|int, mixed>
Get health status
getJob()  : Job|null
Get a specific Job based on id
getJobQueue()  : JobQueue|null
Get the job queue
getJobStates()  : YamlFile
Get the Job states file
getLogger()  : Logger|null
Get the scheduler logger
getQueue()  : JobQueue|null
Get the job queue
getQueuedJobs()  : array<string|int, mixed>
Get the queued jobs as background/foreground
getSchedulerCommand()  : string
getVerboseOutput()  : string|array<string|int, mixed>
Get the scheduler verbose output.
isCrontabSetup()  : int
Helper to determine if cron-like job is setup 0 - Crontab Not found 1 - Crontab Found 2 - Error
isWebhookEnabled()  : bool
Check if webhook is enabled
loadSavedJobs()  : $this
Load saved jobs from config/scheduler.yaml file
processWebhookTrigger()  : array<string|int, mixed>
Process webhook trigger
resetRun()  : $this
Reset all collected data of last run.
run()  : mixed
Run the scheduler.
whoami()  : false|string
Try to determine who's running the process
executeJob()  : void
Execute a job
initializeLogger()  : void
Initialize the scheduler logger
initializeModernFeatures()  : void
Initialize modern features
processJobsWithWorkers()  : void
Process jobs using multiple workers
processQueuedJobs()  : void
Process existing queued jobs
saveJobHistory()  : void
Save job execution history
saveJobState()  : void
Save state for a single job
updateLastRun()  : void
Update last run timestamp
addSchedulerVerboseOutput()  : void
Add an entry to the scheduler verbose output array.
pushExecutedJob()  : Job
Push a succesfully executed job.
pushFailedJob()  : Job
Push a failed job.
queueJob()  : void
Queue a job for execution in the correct queue.
saveJobStates()  : void
Save job states to statys file

Properties

$healthEnabled

protected bool $healthEnabled = true

$logger

protected Logger|null $logger = null

$modernConfig

protected array<string|int, mixed> $modernConfig = []

$webhookEnabled

protected bool $webhookEnabled = false

$webhookToken

protected string|null $webhookToken = null

$workers

protected array<string|int, mixed> $workers = []

$config

private array<string|int, mixed> $config

$executed_jobs

private array<string|int, Job> $executed_jobs = []

$failed_jobs

private array<string|int, Job> $failed_jobs = []

$jobs

private array<string|int, Job> $jobs = []

The queued jobs.

$output_schedule

private array<string|int, mixed> $output_schedule = []

$saved_jobs

private array<string|int, Job> $saved_jobs = []

Methods

__construct()

Create new instance.

public __construct() : mixed

addCommand()

Queue a raw shell command.

public addCommand(string $command[, array<string|int, mixed> $args = [] ][, string|null $id = null ]) : Job
Parameters
$command : string

The command to execute

$args : array<string|int, mixed> = []

Optional arguments to pass to the command

$id : string|null = null

Optional custom identifier

Return values
Job

addFunction()

Queues a PHP function execution.

public addFunction(callable $fn[, array<string|int, mixed> $args = [] ][, string|null $id = null ]) : Job
Parameters
$fn : callable

The function to execute

$args : array<string|int, mixed> = []

Optional arguments to pass to the php script

$id : string|null = null

Optional custom identifier

Return values
Job

clearJobs()

Remove all queued Jobs.

public clearJobs() : $this
Return values
$this

getActiveTriggers()

Get active trigger methods

public getActiveTriggers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllJobs()

Get all jobs if they are disabled or not as one array

public getAllJobs() : array<string|int, Job>
Return values
array<string|int, Job>

getCronCommand()

Helper to get the full Cron command

public getCronCommand() : string
Return values
string

getHealthStatus()

Get health status

public getHealthStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>

getJob()

Get a specific Job based on id

public getJob(string $jobid) : Job|null
Parameters
$jobid : string
Return values
Job|null

getJobStates()

Get the Job states file

public getJobStates() : YamlFile
Return values
YamlFile

getLogger()

Get the scheduler logger

public getLogger() : Logger|null
Return values
Logger|null

getQueuedJobs()

Get the queued jobs as background/foreground

public getQueuedJobs([bool $all = false ]) : array<string|int, mixed>
Parameters
$all : bool = false
Return values
array<string|int, mixed>

getSchedulerCommand()

public getSchedulerCommand([string|null $php = null ]) : string
Parameters
$php : string|null = null
Return values
string

getVerboseOutput()

Get the scheduler verbose output.

public getVerboseOutput([string $type = 'text' ]) : string|array<string|int, mixed>
Parameters
$type : string = 'text'

Allowed: text, html, array

Return values
string|array<string|int, mixed>

The return depends on the requested $type

isCrontabSetup()

Helper to determine if cron-like job is setup 0 - Crontab Not found 1 - Crontab Found 2 - Error

public isCrontabSetup() : int
Return values
int

isWebhookEnabled()

Check if webhook is enabled

public isWebhookEnabled() : bool
Return values
bool

loadSavedJobs()

Load saved jobs from config/scheduler.yaml file

public loadSavedJobs() : $this
Return values
$this

processWebhookTrigger()

Process webhook trigger

public processWebhookTrigger([string|null $token = null ][, string|null $jobId = null ]) : array<string|int, mixed>
Parameters
$token : string|null = null
$jobId : string|null = null
Return values
array<string|int, mixed>

resetRun()

Reset all collected data of last run.

public resetRun() : $this

Call before run() if you call run() multiple times.

Return values
$this

run()

Run the scheduler.

public run([DateTime|null $runTime = null ][, bool $force = false ]) : mixed
Parameters
$runTime : DateTime|null = null

Optional, run at specific moment

$force : bool = false

force run even if not due

whoami()

Try to determine who's running the process

public whoami() : false|string
Return values
false|string

executeJob()

Execute a job

protected executeJob(Job $job[, string|null $queueId = null ]) : void
Parameters
$job : Job
$queueId : string|null = null

Queue ID if job came from queue

initializeLogger()

Initialize the scheduler logger

protected initializeLogger(mixed $locator) : void
Parameters
$locator : mixed

initializeModernFeatures()

Initialize modern features

protected initializeModernFeatures(mixed $locator) : void
Parameters
$locator : mixed

processJobsWithWorkers()

Process jobs using multiple workers

protected processJobsWithWorkers() : void

processQueuedJobs()

Process existing queued jobs

protected processQueuedJobs() : void

saveJobHistory()

Save job execution history

protected saveJobHistory() : void

saveJobState()

Save state for a single job

protected saveJobState(Job $job) : void
Parameters
$job : Job

updateLastRun()

Update last run timestamp

protected updateLastRun() : void

addSchedulerVerboseOutput()

Add an entry to the scheduler verbose output array.

private addSchedulerVerboseOutput(string $string) : void
Parameters
$string : string

pushExecutedJob()

Push a succesfully executed job.

private pushExecutedJob(Job $job) : Job
Parameters
$job : Job
Return values
Job

pushFailedJob()

Push a failed job.

private pushFailedJob(Job $job) : Job
Parameters
$job : Job
Return values
Job

queueJob()

Queue a job for execution in the correct queue.

private queueJob(Job $job) : void
Parameters
$job : Job

saveJobStates()

Save job states to statys file

private saveJobStates() : void

        
On this page

Search results