Event
class Event (View source)
Traits
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 | $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 | $withoutOverlapping | Indicates if the command should not overlap itself. |
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 |
string|null | $command | The command string. |
|
string | $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. |
|
EventMutex | $mutex | The event mutex implementation. |
|
Closure|null | $mutexNameResolver | The mutex name resolver callback. |
|
protected Carbon|null | $lastChecked | The last time the event was checked for eligibility to run. |
|
int|null | $exitCode | The exit status code of the command. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Limit the environments the command should run in.
State that the command should run even in maintenance mode.
Do not allow the event to overlap each other.
Allow the event to only run on one server for each cron expression.
Set the human-friendly description of the event.
Set the human-friendly description of the event.
The Cron expression representing the event's frequency.
Schedule the event to run between start and end time.
Schedule the event to not run between start and end time.
Schedule the event to run every fifteen seconds.
Schedule the event to run multiple times per minute.
Schedule the event to run every fifteen minutes.
Schedule the event to run hourly at a given offset in the hour.
Schedule the event to run every odd hour.
Schedule the event to run every two hours.
Schedule the event to run every three hours.
Schedule the event to run every four hours.
Schedule the event to run every six hours.
Schedule the event to run daily at a given time (10:00, 19:30, etc).
Schedule the event to run twice daily.
Schedule the event to run twice daily at a given offset.
Schedule the event to run at the given minutes and hours.
Schedule the event to run weekly on a given day and time.
Schedule the event to run monthly on a given day and time.
Schedule the event to run twice monthly at a given time.
Schedule the event to run on the last day of the month.
Schedule the event to run quarterly on a given day and time.
Schedule the event to run yearly on a given month, day, and time.
Set the days of the week the command should run on.
Splice the given value into the given position of the expression.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Call the given Closure with this instance then return the instance.
Create a new event instance.
Get the default output depending on the OS.
Determine if the event should skip because another process is overlapping.
Determine if the event has been configured to repeat multiple times per minute.
Determine if the event is ready to repeat.
Build the command string.
Determine if the event runs in maintenance mode.
Determine if the Cron expression passes.
Determine if the event runs in the given environment.
Ensure that the output is stored on disk in a log file.
Send the output of the command to a given location.
Append the output of the command to a given location.
E-mail the results of the scheduled operation.
E-mail the results of the scheduled operation if it produces output.
E-mail the results of the scheduled operation if it fails.
Ensure that the command output is being captured.
E-mail the output of the event to the recipients.
Get the e-mail subject line for output results.
Register a callback to ping a given URL before the job runs.
Register a callback to ping a given URL before the job runs if the given condition is true.
Register a callback to ping a given URL after the job runs.
Register a callback to ping a given URL after the job runs if the given condition is true.
Register a callback to ping a given URL if the operation succeeds.
Register a callback to ping a given URL if the operation succeeds and if the given condition is true.
Register a callback to ping a given URL if the operation fails.
Register a callback to ping a given URL if the operation fails and if the given condition is true.
Get the callback that pings the given URL.
Register a callback that uses the output after the job runs.
Register a callback that uses the output if the operation succeeds.
Register a callback that uses the output if the operation fails.
Get a callback that provides output.
Get the summary of the event for display.
Determine the next due date for an event.
Get the Cron expression for the event.
Get the mutex name for the scheduled command.
Set the mutex name or name resolver callback.
Delete the mutex for the event.
Format the given command string with a normalized PHP binary path.
Details
$this
withoutOverlapping(int $expiresAt = 1440)
Do not allow the event to overlap each other.
The expiration time of the underlying cache lock may be specified in minutes.
$this
between(string $startTime, string $endTime)
Schedule the event to run between start and end time.
$this
unlessBetween(string $startTime, string $endTime)
Schedule the event to not run between start and end time.
protected $this
repeatEvery(int<0, 59> $seconds)
Schedule the event to run multiple times per minute.
$this
hourlyAt(array|string|int<0, 59>|int<0, 59>[] $offset)
Schedule the event to run hourly at a given offset in the hour.
$this
twiceDaily(int<0, 23> $first = 1, int<0, 23> $second = 13)
Schedule the event to run twice daily.
$this
twiceDailyAt(int<0, 23> $first = 1, int<0, 23> $second = 13, int<0, 59> $offset = 0)
Schedule the event to run twice daily at a given offset.
protected $this
hourBasedSchedule(array|string|int<0, 59> $minutes, array|string|int<0, 23> $hours)
Schedule the event to run at the given minutes and hours.
$this
weeklyOn(array|mixed $dayOfWeek, string $time = '0:0')
Schedule the event to run weekly on a given day and time.
$this
monthlyOn(int<1, 31> $dayOfMonth = 1, string $time = '0:0')
Schedule the event to run monthly on a given day and time.
$this
twiceMonthly(int<1, 31> $first = 1, int<1, 31> $second = 16, string $time = '0:0')
Schedule the event to run twice monthly at a given time.
$this
quarterlyOn(int $dayOfQuarter = 1, string $time = '0:0')
Schedule the event to run quarterly on a given day and time.
$this
yearlyOn(int $month = 1, int<1, 31>|string $dayOfMonth = 1, string $time = '0:0')
Schedule the event to run yearly on a given month, day, and time.
protected $this
spliceIntoPosition(int $position, string $value)
Splice the given value into the given position of the expression.
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
__construct(EventMutex $mutex, string $command, DateTimeZone|string|null $timezone = null)
Create a new event instance.
bool
shouldSkipDueToOverlapping()
Determine if the event should skip because another process is overlapping.
void
finish(Container $container, int $exitCode)
Mark the command process as finished and run callbacks/cleanup.
$this
sendOutputTo(string $location, bool $append = false)
Send the output of the command to a given location.
$this
emailOutputTo(array|mixed $addresses, bool $onlyIfOutputExists = true)
E-mail the results of the scheduled operation.
$this
emailWrittenOutputTo(array|mixed $addresses)
E-mail the results of the scheduled operation if it produces output.
$this
emailOutputOnFailure(array|mixed $addresses)
E-mail the results of the scheduled operation if it fails.
protected void
emailOutput(Mailer $mailer, array $addresses, bool $onlyIfOutputExists = true)
E-mail the output of the event to the recipients.
$this
pingBeforeIf(bool $value, string $url)
Register a callback to ping a given URL before the job runs if the given condition is true.
$this
thenPingIf(bool $value, string $url)
Register a callback to ping a given URL after the job runs if the given condition is true.
$this
pingOnSuccessIf(bool $value, string $url)
Register a callback to ping a given URL if the operation succeeds and if the given condition is true.
$this
pingOnFailureIf(bool $value, string $url)
Register a callback to ping a given URL if the operation fails and if the given condition is true.
protected ClientInterface
getHttpClient(Container $container)
Get the Guzzle HTTP client to use to send pings.
$this
thenWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
Register a callback that uses the output after the job runs.
$this
onSuccessWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
Register a callback that uses the output if the operation succeeds.
$this
onFailureWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
Register a callback that uses the output if the operation fails.
protected Closure
withOutputCallback(Closure $callback, bool $onlyIfOutputExists = false)
Get a callback that provides output.
Carbon
nextRunDate(DateTimeInterface|string $currentTime = 'now', int $nth = 0, bool $allowCurrentDate = false)
Determine the next due date for an event.