class Event

Traits

Constants

protected EXIT_CODE_CONTEXT_KEY_PREFIX

Context key prefix for the current run's exit code.

protected PROCESS_CONTEXT_KEY_PREFIX

Context key prefix for the current run's process.

protected SKIPPED_BECAUSE_OVERLAPPING_CONTEXT_KEY_PREFIX

Context key prefix for the current run's overlap skip state.

Properties

static protected array $macros

The registered string macros.

from  Macroable
string $expression

The cron expression representing the event's frequency.

from  ManagesAttributes
int|null $repeatSeconds

How often to repeat the event during a minute.

from  ManagesAttributes
DateTimeZone|string|null $timezone

The timezone the date should be evaluated on.

from  ManagesAttributes
string|null $user

The user the command should run as.

from  ManagesAttributes
array $environments

The list of environments the command should run under.

from  ManagesAttributes
bool $evenInMaintenanceMode

Indicates if the command should run in maintenance mode.

from  ManagesAttributes
bool $evenWhenPaused

Indicates if the command should run when the scheduler is paused.

from  ManagesAttributes
bool $withoutOverlapping

Indicates if the command should not overlap itself.

from  ManagesAttributes
bool $releaseOnTerminationSignals

Indicates if the event mutex should be released on termination signals.

from  ManagesAttributes
bool $onOneServer

Indicates if the command should only be allowed to run on one server for each cron expression.

from  ManagesAttributes
int $expiresAt

The number of minutes the mutex should be valid.

from  ManagesAttributes
bool $runInBackground

Indicates if the command should run in the background.

from  ManagesAttributes
protected array $filters

The array of filter callbacks.

from  ManagesAttributes
protected array $rejects

The array of reject callbacks.

from  ManagesAttributes
string|null $description

The human readable description of the event.

from  ManagesAttributes
array $attributes

The arbitrary attributes assigned to the event.

from  ManagesAttributes
string|null $command

The command string.

string|null $output

The location that output should be sent to.

bool $shouldAppendOutput

Indicates whether output should be appended.

protected array $beforeCallbacks

The array of callbacks to be run before the event is started.

protected array $afterCallbacks

The array of callbacks to be run after the event is finished.

Closure|null $mutexNameResolver

The mutex name resolver callback.

CarbonInterface|null $lastChecked

The last time the event was checked for eligibility to run.

int|null $exitCode

The exit status code of the command.

bool $isSystem

Determines if the event is system command.

protected bool $ensureOutputIsBeingCaptured

Determines if output should be captured.

bool $skippedBecauseOverlapping

Indicates whether the execution was skipped due to the mutex already being reserved.

protected bool $mutexAcquired

Indicates whether this event currently owns the overlapping mutex.

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

user(string $user)

Set which user the command should run as.

environments(mixed $environments)

Limit the environments the command should run in.

evenInMaintenanceMode()

State that the command should run even in maintenance mode.

evenWhenPaused()

State that the command should run even when the scheduler is paused.

withoutOverlapping(int $expiresAt = 1440, bool $releaseOnTerminationSignals = true)

Do not allow the event to overlap each other.

onOneServer()

Allow the event to only run on one server for each cron expression.

runInBackground()

State that the command should run in the background.

when(bool|callable $callback)

Register a callback to further filter the schedule.

skip(bool|callable $callback)

Register a callback to further filter the schedule.

name(string $description)

Set the human-friendly description of the event.

description(string $description)

Set the human-friendly description of the event.

withAttributes(array $attributes)

Set arbitrary attributes to store with the event.

cron(string $expression)

The Cron expression representing the event's frequency.

between(string $startTime, string $endTime)

Schedule the event to run between start and end time.

unlessBetween(string $startTime, string $endTime)

Schedule the event to not run between start and end time.

everySecond()

Schedule the event to run every second.

everyTwoSeconds()

Schedule the event to run every two seconds.

everyFiveSeconds()

Schedule the event to run every five seconds.

everyTenSeconds()

Schedule the event to run every ten seconds.

everyFifteenSeconds()

Schedule the event to run every fifteen seconds.

everyTwentySeconds()

Schedule the event to run every twenty seconds.

everyThirtySeconds()

Schedule the event to run every thirty seconds.

repeatEvery(int $seconds)

Schedule the event to run multiple times per minute.

everyMinute()

Schedule the event to run every minute.

everyTwoMinutes()

Schedule the event to run every two minutes.

everyThreeMinutes()

Schedule the event to run every three minutes.

everyFourMinutes()

Schedule the event to run every four minutes.

everyFiveMinutes()

Schedule the event to run every five minutes.

everyTenMinutes()

Schedule the event to run every ten minutes.

everyFifteenMinutes()

Schedule the event to run every fifteen minutes.

everyThirtyMinutes()

Schedule the event to run every thirty minutes.

hourly()

Schedule the event to run hourly.

hourlyAt(array|int|string $offset)

Schedule the event to run hourly at a given offset in the hour.

everyOddHour(array|int|string $offset = 0)

Schedule the event to run every odd hour.

everyTwoHours(array|int|string $offset = 0)

Schedule the event to run every two hours.

everyThreeHours(array|int|string $offset = 0)

Schedule the event to run every three hours.

everyFourHours(array|int|string $offset = 0)

Schedule the event to run every four hours.

everySixHours(array|int|string $offset = 0)

Schedule the event to run every six hours.

daily()

Schedule the event to run daily.

at(string $time)

Schedule the command at a given time.

dailyAt(string $time)

Schedule the event to run daily at a given time (10:00, 19:30, etc).

twiceDaily(int $first = 1, int $second = 13)

Schedule the event to run twice daily.

twiceDailyAt(int $first = 1, int $second = 13, int $offset = 0)

Schedule the event to run twice daily at a given offset.

hourBasedSchedule(array|int|string $minutes, array|int|string $hours)

Schedule the event to run at the given minutes and hours.

weekdays()

Schedule the event to run only on weekdays.

weekends()

Schedule the event to run only on weekends.

mondays()

Schedule the event to run only on Mondays.

tuesdays()

Schedule the event to run only on Tuesdays.

wednesdays()

Schedule the event to run only on Wednesdays.

thursdays()

Schedule the event to run only on Thursdays.

fridays()

Schedule the event to run only on Fridays.

saturdays()

Schedule the event to run only on Saturdays.

sundays()

Schedule the event to run only on Sundays.

weekly()

Schedule the event to run weekly.

weeklyOn(mixed $dayOfWeek, string $time = '0:0')

Schedule the event to run weekly on a given day and time.

monthly()

Schedule the event to run monthly.

monthlyOn(int $dayOfMonth = 1, string $time = '0:0')

Schedule the event to run monthly on a given day and time.

twiceMonthly(int $first = 1, int $second = 16, string $time = '0:0')

Schedule the event to run twice monthly at a given time.

lastDayOfMonth(string $time = '0:0')

Schedule the event to run on the last day of the month.

daysOfMonth(int|array ...$days)

Schedule the event to run on specific days of the month.

quarterly()

Schedule the event to run quarterly.

quarterlyOn(int $dayOfQuarter = 1, string $time = '0:0')

Schedule the event to run quarterly on a given day and time.

yearly()

Schedule the event to run yearly.

yearlyOn(int $month = 1, int|string $dayOfMonth = 1, string $time = '0:0')

Schedule the event to run yearly on a given month, day, and time.

days(mixed $days)

Set the days of the week the command should run on.

timezone(DateTimeZone|UnitEnum|string $timezone)

Set the timezone the date should be evaluated on.

spliceIntoPosition(int $position, int|string $value)

Splice the given value into the given position of the expression.

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

mixed
tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

from  Tappable
__construct(EventMutex $mutex, string|null $command = null, DateTimeZone|string|null $timezone = null, bool $isSystem = false)

Create a new event instance.

mixed
run(Container $container)

Run the given event.

bool
shouldSkipDueToOverlapping()

Determine if the event should skip because another process is overlapping.

bool
isRepeatable()

Determine if the event has been configured to repeat multiple times per minute.

bool
shouldRepeatNow()

Determine if the event is ready to repeat.

int
start(Container $container)

Run the command process.

int
execute(Container $container)

Run the command process.

int
runProcess(Container $container)

Run the system command process.

string|null
getProcessOutput()

Get the output of the system command process.

void
finish(Container $container, int $exitCode)

Mark the command process as finished and run callbacks/cleanup.

void
callBeforeCallbacks(Container $container)

Call all of the "before" callbacks for the event.

void
callAfterCallbacks(Container $container)

Call all of the "after" callbacks for the event.

bool
isDue(Application $app)

Determine if the given event should run based on the Cron expression.

bool
isDueAt(Application $app, DateTimeInterface $time)

Determine if the given event should run based on the Cron expression at the given time.

bool
runsInMaintenanceMode()

Determine if the event runs in maintenance mode.

bool
runsWhenPaused()

Determine if the event runs when the scheduler is paused.

bool
expressionPasses(DateTimeInterface $time)

Determine if the Cron expression passes.

bool
runsInEnvironment(string $environment)

Determine if the event runs in the given environment.

bool
filtersPass(Application $app)

Determine if the filters pass for the event.

storeOutput()

Ensure that the output is stored on disk in a log file.

sendOutputTo(string $location, bool $append = false)

Send the output of the command to a given location.

void
writeOutput(Container $container)

Write the output of the command to the destination file.

string|null
getOutput(Container $container)

Get the output for the event.

appendOutputTo(string $location)

Append the output of the command to a given location.

emailOutputTo(mixed $addresses, bool $onlyIfOutputExists = true)

E-mail the results of the scheduled operation.

emailWrittenOutputTo(mixed $addresses)

E-mail the results of the scheduled operation if it produces output.

emailOutputOnFailure(mixed $addresses)

E-mail the results of the scheduled operation if it fails.

void
ensureOutputIsBeingCaptured()

Ensure that the command output is being captured.

void
emailOutput(Mailer $mailer, Filesystem $filesystem, mixed $addresses, bool $onlyIfOutputExists = true)

E-mail the output of the event to the recipients.

string
getEmailSubject()

Get the e-mail subject line for output results.

pingBefore(string $url)

Register a callback to ping a given URL before the job runs.

pingBeforeIf(bool $value, string $url)

Register a callback to ping a given URL before the job runs if the given condition is true.

thenPing(string $url)

Register a callback to ping a given URL after the job runs.

thenPingIf(bool $value, string $url)

Register a callback to ping a given URL after the job runs if the given condition is true.

pingOnSuccess(string $url)

Register a callback to ping a given URL if the operation succeeds.

pingOnSuccessIf(bool $value, string $url)

Register a callback to ping a given URL if the operation succeeds and if the given condition is true.

pingOnFailure(string $url)

Register a callback to ping a given URL if the operation fails.

pingOnFailureIf(bool $value, string $url)

Register a callback to ping a given URL if the operation fails and if the given condition is true.

pingCallback(string $url)

Get the callback that pings the given URL.

ClientInterface
getHttpClient(Container $container)

Get the Guzzle HTTP client to use to send pings.

before(Closure $callback)

Register a callback to be called before the operation.

after(Closure $callback)

Register a callback to be called after the operation.

then(Closure $callback)

Register a callback to be called after the operation.

thenWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output after the job runs.

onSuccess(Closure $callback)

Register a callback to be called if the operation succeeds.

onSuccessWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output if the operation succeeds.

onFailure(Closure $callback)

Register a callback to be called if the operation fails.

onFailureWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output if the operation fails.

withOutputCallback(Closure $callback, bool $onlyIfOutputExists = false)

Get a callback that provides output.

string
readOutput(Filesystem $filesystem)

Read the captured event output.

mixed
callEventCallback(Container $container, callable $callback, array $parameters = [])

Call the given event callback.

array
eventParametersForCallback(Closure $callback)

Get the event parameters for the given callback.

string
getSummaryForDisplay()

Get the summary of the event for display.

CarbonInterface
nextRunDate(DateTimeInterface|string $currentTime = 'now', int $nth = 0, bool $allowCurrentDate = false)

Determine the next due date for an event.

string
getExpression()

Get the Cron expression for the event.

preventOverlapsUsing(EventMutex $mutex)

Set the event mutex implementation to be used.

string
mutexName()

Get the mutex name for the scheduled command.

createMutexNameUsing(Closure|string $mutexName)

Set the mutex name or name resolver callback.

void
releaseMutexOnTerminationSignal()

Release the event mutex if this process owns it during signal termination.

void
removeMutex()

Delete the mutex for the event.

void
setExitCode(int $exitCode)

Set the exit code for the current event run.

int|null
exitCode()

Get the exit code for the current event run.

bool
wasSkippedDueToOverlapping()

Determine if this event's most recent run in the current coroutine was skipped due to overlapping.

string
exitCodeContextKey()

Get the context key for this event's current run.

string
processContextKey()

Get the context key for this event's current process.

string
skippedBecauseOverlappingContextKey()

Get the context key for this event's overlap skip state.

static string
normalizeCommand(string $command)

Format the given command string with a normalized PHP binary path.

static void
flushState()

Flush all static state.

Details

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ManagesAttributes at line 95
ManagesAttributes user(string $user)

Set which user the command should run as.

Parameters

string $user

Return Value

ManagesAttributes

in ManagesAttributes at line 107
ManagesAttributes environments(mixed $environments)

Limit the environments the command should run in.

Parameters

mixed $environments

Return Value

ManagesAttributes

in ManagesAttributes at line 117
ManagesAttributes evenInMaintenanceMode()

State that the command should run even in maintenance mode.

Return Value

ManagesAttributes

in ManagesAttributes at line 127
ManagesAttributes evenWhenPaused()

State that the command should run even when the scheduler is paused.

Return Value

ManagesAttributes

in ManagesAttributes at line 138
ManagesAttributes withoutOverlapping(int $expiresAt = 1440, bool $releaseOnTerminationSignals = true)

Do not allow the event to overlap each other.

The expiration time of the underlying cache lock may be specified in minutes.

Parameters

int $expiresAt
bool $releaseOnTerminationSignals

Return Value

ManagesAttributes

in ManagesAttributes at line 154
ManagesAttributes onOneServer()

Allow the event to only run on one server for each cron expression.

Return Value

ManagesAttributes

in ManagesAttributes at line 164
ManagesAttributes runInBackground()

State that the command should run in the background.

Return Value

ManagesAttributes

in ManagesAttributes at line 174
ManagesAttributes when(bool|callable $callback)

Register a callback to further filter the schedule.

Parameters

bool|callable $callback

Return Value

ManagesAttributes

in ManagesAttributes at line 186
ManagesAttributes skip(bool|callable $callback)

Register a callback to further filter the schedule.

Parameters

bool|callable $callback

Return Value

ManagesAttributes

in ManagesAttributes at line 198
ManagesAttributes name(string $description)

Set the human-friendly description of the event.

Parameters

string $description

Return Value

ManagesAttributes

in ManagesAttributes at line 206
ManagesAttributes description(string $description)

Set the human-friendly description of the event.

Parameters

string $description

Return Value

ManagesAttributes

in ManagesAttributes at line 216
ManagesAttributes withAttributes(array $attributes)

Set arbitrary attributes to store with the event.

Parameters

array $attributes

Return Value

ManagesAttributes

in ManagesFrequencies at line 20
ManagesFrequencies cron(string $expression)

The Cron expression representing the event's frequency.

Parameters

string $expression

Return Value

ManagesFrequencies

in ManagesFrequencies at line 30
ManagesFrequencies between(string $startTime, string $endTime)

Schedule the event to run between start and end time.

Parameters

string $startTime
string $endTime

Return Value

ManagesFrequencies

in ManagesFrequencies at line 38
ManagesFrequencies unlessBetween(string $startTime, string $endTime)

Schedule the event to not run between start and end time.

Parameters

string $startTime
string $endTime

Return Value

ManagesFrequencies

in ManagesFrequencies at line 70
ManagesFrequencies everySecond()

Schedule the event to run every second.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 78
ManagesFrequencies everyTwoSeconds()

Schedule the event to run every two seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 86
ManagesFrequencies everyFiveSeconds()

Schedule the event to run every five seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 94
ManagesFrequencies everyTenSeconds()

Schedule the event to run every ten seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 102
ManagesFrequencies everyFifteenSeconds()

Schedule the event to run every fifteen seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 110
ManagesFrequencies everyTwentySeconds()

Schedule the event to run every twenty seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 118
ManagesFrequencies everyThirtySeconds()

Schedule the event to run every thirty seconds.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 128
protected ManagesFrequencies repeatEvery(int $seconds)

Schedule the event to run multiple times per minute.

Parameters

int $seconds

Return Value

ManagesFrequencies

in ManagesFrequencies at line 146
ManagesFrequencies everyMinute()

Schedule the event to run every minute.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 154
ManagesFrequencies everyTwoMinutes()

Schedule the event to run every two minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 162
ManagesFrequencies everyThreeMinutes()

Schedule the event to run every three minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 170
ManagesFrequencies everyFourMinutes()

Schedule the event to run every four minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 178
ManagesFrequencies everyFiveMinutes()

Schedule the event to run every five minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 186
ManagesFrequencies everyTenMinutes()

Schedule the event to run every ten minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 194
ManagesFrequencies everyFifteenMinutes()

Schedule the event to run every fifteen minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 202
ManagesFrequencies everyThirtyMinutes()

Schedule the event to run every thirty minutes.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 210
ManagesFrequencies hourly()

Schedule the event to run hourly.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 220
ManagesFrequencies hourlyAt(array|int|string $offset)

Schedule the event to run hourly at a given offset in the hour.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 228
ManagesFrequencies everyOddHour(array|int|string $offset = 0)

Schedule the event to run every odd hour.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 236
ManagesFrequencies everyTwoHours(array|int|string $offset = 0)

Schedule the event to run every two hours.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 244
ManagesFrequencies everyThreeHours(array|int|string $offset = 0)

Schedule the event to run every three hours.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 252
ManagesFrequencies everyFourHours(array|int|string $offset = 0)

Schedule the event to run every four hours.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 260
ManagesFrequencies everySixHours(array|int|string $offset = 0)

Schedule the event to run every six hours.

Parameters

array|int|string $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 268
ManagesFrequencies daily()

Schedule the event to run daily.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 276
ManagesFrequencies at(string $time)

Schedule the command at a given time.

Parameters

string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 284
ManagesFrequencies dailyAt(string $time)

Schedule the event to run daily at a given time (10:00, 19:30, etc).

Parameters

string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 300
ManagesFrequencies twiceDaily(int $first = 1, int $second = 13)

Schedule the event to run twice daily.

Parameters

int $first
int $second

Return Value

ManagesFrequencies

in ManagesFrequencies at line 312
ManagesFrequencies twiceDailyAt(int $first = 1, int $second = 13, int $offset = 0)

Schedule the event to run twice daily at a given offset.

Parameters

int $first
int $second
int $offset

Return Value

ManagesFrequencies

in ManagesFrequencies at line 325
protected hourBasedSchedule(array|int|string $minutes, array|int|string $hours)

Schedule the event to run at the given minutes and hours.

Parameters

array|int|string $minutes
array|int|string $hours

in ManagesFrequencies at line 338
ManagesFrequencies weekdays()

Schedule the event to run only on weekdays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 346
ManagesFrequencies weekends()

Schedule the event to run only on weekends.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 354
ManagesFrequencies mondays()

Schedule the event to run only on Mondays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 362
ManagesFrequencies tuesdays()

Schedule the event to run only on Tuesdays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 370
ManagesFrequencies wednesdays()

Schedule the event to run only on Wednesdays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 378
ManagesFrequencies thursdays()

Schedule the event to run only on Thursdays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 386
ManagesFrequencies fridays()

Schedule the event to run only on Fridays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 394
ManagesFrequencies saturdays()

Schedule the event to run only on Saturdays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 402
ManagesFrequencies sundays()

Schedule the event to run only on Sundays.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 410
ManagesFrequencies weekly()

Schedule the event to run weekly.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 422
ManagesFrequencies weeklyOn(mixed $dayOfWeek, string $time = '0:0')

Schedule the event to run weekly on a given day and time.

Parameters

mixed $dayOfWeek
string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 432
ManagesFrequencies monthly()

Schedule the event to run monthly.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 444
ManagesFrequencies monthlyOn(int $dayOfMonth = 1, string $time = '0:0')

Schedule the event to run monthly on a given day and time.

Parameters

int $dayOfMonth
string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 457
ManagesFrequencies twiceMonthly(int $first = 1, int $second = 16, string $time = '0:0')

Schedule the event to run twice monthly at a given time.

Parameters

int $first
int $second
string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 469
ManagesFrequencies lastDayOfMonth(string $time = '0:0')

Schedule the event to run on the last day of the month.

Parameters

string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 481
ManagesFrequencies daysOfMonth(int|array ...$days)

Schedule the event to run on specific days of the month.

Parameters

int|array ...$days

Return Value

ManagesFrequencies

in ManagesFrequencies at line 494
ManagesFrequencies quarterly()

Schedule the event to run quarterly.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 505
ManagesFrequencies quarterlyOn(int $dayOfQuarter = 1, string $time = '0:0')

Schedule the event to run quarterly on a given day and time.

Parameters

int $dayOfQuarter
string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 516
ManagesFrequencies yearly()

Schedule the event to run yearly.

Return Value

ManagesFrequencies

in ManagesFrequencies at line 527
ManagesFrequencies yearlyOn(int $month = 1, int|string $dayOfMonth = 1, string $time = '0:0')

Schedule the event to run yearly on a given month, day, and time.

Parameters

int $month
int|string $dayOfMonth
string $time

Return Value

ManagesFrequencies

in ManagesFrequencies at line 540
ManagesFrequencies days(mixed $days)

Set the days of the week the command should run on.

Parameters

mixed $days

Return Value

ManagesFrequencies

in ManagesFrequencies at line 550
ManagesFrequencies timezone(DateTimeZone|UnitEnum|string $timezone)

Set the timezone the date should be evaluated on.

Parameters

DateTimeZone|UnitEnum|string $timezone

Return Value

ManagesFrequencies

in ManagesFrequencies at line 562
protected ManagesFrequencies spliceIntoPosition(int $position, int|string $value)

Splice the given value into the given position of the expression.

Parameters

int $position
int|string $value

Return Value

ManagesFrequencies

in ReflectsClosures at line 25
protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 48
protected array firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 74
protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in ReflectsClosures at line 94
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in Tappable at line 15
mixed tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

Parameters

callable|null $callback

Return Value

mixed

at line 132
__construct(EventMutex $mutex, string|null $command = null, DateTimeZone|string|null $timezone = null, bool $isSystem = false)

Create a new event instance.

Parameters

EventMutex $mutex

the event mutex implementation

string|null $command

the command string

DateTimeZone|string|null $timezone
bool $isSystem

at line 148
mixed run(Container $container)

Run the given event.

Parameters

Container $container

Return Value

mixed

Exceptions

Throwable

at line 205
bool shouldSkipDueToOverlapping()

Determine if the event should skip because another process is overlapping.

Return Value

bool

at line 223
bool isRepeatable()

Determine if the event has been configured to repeat multiple times per minute.

Return Value

bool

at line 231
bool shouldRepeatNow()

Determine if the event is ready to repeat.

Return Value

bool

at line 242
protected int start(Container $container)

Run the command process.

Parameters

Container $container

Return Value

int

Exceptions

Throwable

at line 252
protected int execute(Container $container)

Run the command process.

Parameters

Container $container

Return Value

int

at line 265
protected int runProcess(Container $container)

Run the system command process.

Parameters

Container $container

Return Value

int

at line 281
protected string|null getProcessOutput()

Get the output of the system command process.

Return Value

string|null

at line 293
void finish(Container $container, int $exitCode)

Mark the command process as finished and run callbacks/cleanup.

Parameters

Container $container
int $exitCode

Return Value

void

at line 325
void callBeforeCallbacks(Container $container)

Call all of the "before" callbacks for the event.

Parameters

Container $container

Return Value

void

at line 335
void callAfterCallbacks(Container $container)

Call all of the "after" callbacks for the event.

Parameters

Container $container

Return Value

void

at line 345
bool isDue(Application $app)

Determine if the given event should run based on the Cron expression.

Parameters

Application $app

Return Value

bool

at line 353
bool isDueAt(Application $app, DateTimeInterface $time)

Determine if the given event should run based on the Cron expression at the given time.

Parameters

Application $app
DateTimeInterface $time

Return Value

bool

at line 366
bool runsInMaintenanceMode()

Determine if the event runs in maintenance mode.

Return Value

bool

at line 374
bool runsWhenPaused()

Determine if the event runs when the scheduler is paused.

Return Value

bool

at line 382
protected bool expressionPasses(DateTimeInterface $time)

Determine if the Cron expression passes.

Parameters

DateTimeInterface $time

Return Value

bool

at line 397
bool runsInEnvironment(string $environment)

Determine if the event runs in the given environment.

Parameters

string $environment

Return Value

bool

at line 406
bool filtersPass(Application $app)

Determine if the filters pass for the event.

Parameters

Application $app

Return Value

bool

at line 428
Event storeOutput()

Ensure that the output is stored on disk in a log file.

Return Value

Event

at line 438
Event sendOutputTo(string $location, bool $append = false)

Send the output of the command to a given location.

Parameters

string $location
bool $append

Return Value

Event

at line 450
void writeOutput(Container $container)

Write the output of the command to the destination file.

Parameters

Container $container

Return Value

void

at line 473
string|null getOutput(Container $container)

Get the output for the event.

Parameters

Container $container

Return Value

string|null

at line 485
Event appendOutputTo(string $location)

Append the output of the command to a given location.

Parameters

string $location

Return Value

Event

at line 495
Event emailOutputTo(mixed $addresses, bool $onlyIfOutputExists = true)

E-mail the results of the scheduled operation.

Parameters

mixed $addresses
bool $onlyIfOutputExists

Return Value

Event

Exceptions

LogicException

at line 513
Event emailWrittenOutputTo(mixed $addresses)

E-mail the results of the scheduled operation if it produces output.

Parameters

mixed $addresses

Return Value

Event

Exceptions

LogicException

at line 523
Event emailOutputOnFailure(mixed $addresses)

E-mail the results of the scheduled operation if it fails.

Parameters

mixed $addresses

Return Value

Event

at line 537
protected void ensureOutputIsBeingCaptured()

Ensure that the command output is being captured.

Return Value

void

at line 548
protected void emailOutput(Mailer $mailer, Filesystem $filesystem, mixed $addresses, bool $onlyIfOutputExists = true)

E-mail the output of the event to the recipients.

Parameters

Mailer $mailer
Filesystem $filesystem
mixed $addresses
bool $onlyIfOutputExists

Return Value

void

at line 568
protected string getEmailSubject()

Get the e-mail subject line for output results.

Return Value

string

at line 580
Event pingBefore(string $url)

Register a callback to ping a given URL before the job runs.

Parameters

string $url

Return Value

Event

at line 588
Event pingBeforeIf(bool $value, string $url)

Register a callback to ping a given URL before the job runs if the given condition is true.

Parameters

bool $value
string $url

Return Value

Event

at line 596
Event thenPing(string $url)

Register a callback to ping a given URL after the job runs.

Parameters

string $url

Return Value

Event

at line 604
Event thenPingIf(bool $value, string $url)

Register a callback to ping a given URL after the job runs if the given condition is true.

Parameters

bool $value
string $url

Return Value

Event

at line 612
Event pingOnSuccess(string $url)

Register a callback to ping a given URL if the operation succeeds.

Parameters

string $url

Return Value

Event

at line 620
Event pingOnSuccessIf(bool $value, string $url)

Register a callback to ping a given URL if the operation succeeds and if the given condition is true.

Parameters

bool $value
string $url

Return Value

Event

at line 628
Event pingOnFailure(string $url)

Register a callback to ping a given URL if the operation fails.

Parameters

string $url

Return Value

Event

at line 636
Event pingOnFailureIf(bool $value, string $url)

Register a callback to ping a given URL if the operation fails and if the given condition is true.

Parameters

bool $value
string $url

Return Value

Event

at line 644
protected Closure pingCallback(string $url)

Get the callback that pings the given URL.

Parameters

string $url

Return Value

Closure

at line 658
protected ClientInterface getHttpClient(Container $container)

Get the Guzzle HTTP client to use to send pings.

Parameters

Container $container

Return Value

ClientInterface

at line 674
Event before(Closure $callback)

Register a callback to be called before the operation.

Parameters

Closure $callback

Return Value

Event

at line 684
Event after(Closure $callback)

Register a callback to be called after the operation.

Parameters

Closure $callback

Return Value

Event

at line 692
Event then(Closure $callback)

Register a callback to be called after the operation.

Parameters

Closure $callback

Return Value

Event

at line 708
Event thenWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output after the job runs.

Parameters

Closure $callback
bool $onlyIfOutputExists

Return Value

Event

at line 718
Event onSuccess(Closure $callback)

Register a callback to be called if the operation succeeds.

Parameters

Closure $callback

Return Value

Event

at line 736
Event onSuccessWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output if the operation succeeds.

Parameters

Closure $callback
bool $onlyIfOutputExists

Return Value

Event

at line 746
Event onFailure(Closure $callback)

Register a callback to be called if the operation fails.

Parameters

Closure $callback

Return Value

Event

at line 764
Event onFailureWithOutput(Closure $callback, bool $onlyIfOutputExists = false)

Register a callback that uses the output if the operation fails.

Parameters

Closure $callback
bool $onlyIfOutputExists

Return Value

Event

at line 774
protected Closure withOutputCallback(Closure $callback, bool $onlyIfOutputExists = false)

Get a callback that provides output.

Parameters

Closure $callback
bool $onlyIfOutputExists

Return Value

Closure

at line 788
protected string readOutput(Filesystem $filesystem)

Read the captured event output.

Parameters

Filesystem $filesystem

Return Value

string

at line 802
protected mixed callEventCallback(Container $container, callable $callback, array $parameters = [])

Call the given event callback.

Parameters

Container $container
callable $callback
array $parameters

Return Value

mixed

at line 819
protected array eventParametersForCallback(Closure $callback)

Get the event parameters for the given callback.

Parameters

Closure $callback

Return Value

array

at line 835
string getSummaryForDisplay()

Get the summary of the event for display.

Return Value

string

at line 847
CarbonInterface nextRunDate(DateTimeInterface|string $currentTime = 'now', int $nth = 0, bool $allowCurrentDate = false)

Determine the next due date for an event.

Parameters

DateTimeInterface|string $currentTime
int $nth
bool $allowCurrentDate

Return Value

CarbonInterface

at line 856
string getExpression()

Get the Cron expression for the event.

Return Value

string

at line 864
Event preventOverlapsUsing(EventMutex $mutex)

Set the event mutex implementation to be used.

Parameters

EventMutex $mutex

Return Value

Event

at line 874
string mutexName()

Get the mutex name for the scheduled command.

Return Value

string

at line 889
Event createMutexNameUsing(Closure|string $mutexName)

Set the mutex name or name resolver callback.

Parameters

Closure|string $mutexName

Return Value

Event

at line 901
void releaseMutexOnTerminationSignal()

Release the event mutex if this process owns it during signal termination.

Return Value

void

at line 911
protected void removeMutex()

Delete the mutex for the event.

Return Value

void

at line 925
protected void setExitCode(int $exitCode)

Set the exit code for the current event run.

Parameters

int $exitCode

Return Value

void

at line 937
int|null exitCode()

Get the exit code for the current event run.

Return Value

int|null

at line 945
bool wasSkippedDueToOverlapping()

Determine if this event's most recent run in the current coroutine was skipped due to overlapping.

Return Value

bool

at line 956
protected string exitCodeContextKey()

Get the context key for this event's current run.

Return Value

string

at line 964
protected string processContextKey()

Get the context key for this event's current process.

Return Value

string

at line 972
protected string skippedBecauseOverlappingContextKey()

Get the context key for this event's overlap skip state.

Return Value

string

at line 980
static string normalizeCommand(string $command)

Format the given command string with a normalized PHP binary path.

Parameters

string $command

Return Value

string

at line 994
static void flushState()

Flush all static state.

Return Value

void