CallbackEvent
class CallbackEvent extends 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.  | 
                from Event | 
| string | $output | The location that output should be sent to.  | 
                from Event | 
| bool | $shouldAppendOutput | Indicates whether output should be appended.  | 
                from Event | 
| protected array | $beforeCallbacks | The array of callbacks to be run before the event is started.  | 
                from Event | 
| protected array | $afterCallbacks | The array of callbacks to be run after the event is finished.  | 
                from Event | 
| EventMutex | $mutex | The event mutex implementation.  | 
                from Event | 
| Closure|null | $mutexNameResolver | The mutex name resolver callback.  | 
                from Event | 
| protected Carbon|null | $lastChecked | The last time the event was checked for eligibility to run.  | 
                from Event | 
| int|null | $exitCode | The exit status code of the command.  | 
                from Event | 
| protected string | $callback | The callback to call.  | 
                |
| protected array | $parameters | The parameters to pass to the method.  | 
                |
| protected mixed | $result | The result of the callback's execution.  | 
                |
| protected Throwable|null | $exception | The exception that was thrown when calling the callback, if any.  | 
                
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.
Indicate that the callback should run in the background.
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.
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.
Determine if the event should skip because another process is overlapping.
Determine if the event has been configured to repeat multiple times per minute.
Mark the command process as finished and run callbacks/cleanup.
Determine if the event runs in the given environment.
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.
E-mail the output of the event to the recipients.
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 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.
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 mutex name for the scheduled command.
Set the mutex name or name resolver callback.
Clear the mutex for the event.
Format the given command string with a normalized PHP binary path.
Details
        
                static            void
    macro(string $name, object|callable $macro)
        
    
    Register a custom macro.
        
                static            void
    mixin(object $mixin, bool $replace = true)
        
    
    Mix another object into the class.
        
                static            bool
    hasMacro(string $name)
        
    
    Checks 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.
        
                            $this
    user(string $user)
        
    
    Set which user the command should run as.
        
                            $this
    environments(mixed $environments)
        
    
    Limit the environments the command should run in.
        
                            $this
    evenInMaintenanceMode()
        
    
    State that the command should run even in maintenance mode.
        
                            $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
    onOneServer()
        
    
    Allow the event to only run on one server for each cron expression.
        
                            $this
    runInBackground()
        
    
    Indicate that the callback should run in the background.
        
                            $this
    when(Closure|bool $callback)
        
    
    Register a callback to further filter the schedule.
        
                            $this
    skip(Closure|bool $callback)
        
    
    Register a callback to further filter the schedule.
        
                            $this
    name(string $description)
        
    
    Set the human-friendly description of the event.
        
                            $this
    description(string $description)
        
    
    Set the human-friendly description of the event.
        
                            $this
    cron(string $expression)
        
    
    The Cron expression representing the event's frequency.
        
                            $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.
        
                            $this
    everySecond()
        
    
    Schedule the event to run every second.
        
                            $this
    everyTwoSeconds()
        
    
    Schedule the event to run every two seconds.
        
                            $this
    everyFiveSeconds()
        
    
    Schedule the event to run every five seconds.
        
                            $this
    everyTenSeconds()
        
    
    Schedule the event to run every ten seconds.
        
                            $this
    everyFifteenSeconds()
        
    
    Schedule the event to run every fifteen seconds.
        
                            $this
    everyTwentySeconds()
        
    
    Schedule the event to run every twenty seconds.
        
                            $this
    everyThirtySeconds()
        
    
    Schedule the event to run every thirty seconds.
        
                    protected        $this
    repeatEvery(int<0, 59> $seconds)
        
    
    Schedule the event to run multiple times per minute.
        
                            $this
    everyMinute()
        
    
    Schedule the event to run every minute.
        
                            $this
    everyTwoMinutes()
        
    
    Schedule the event to run every two minutes.
        
                            $this
    everyThreeMinutes()
        
    
    Schedule the event to run every three minutes.
        
                            $this
    everyFourMinutes()
        
    
    Schedule the event to run every four minutes.
        
                            $this
    everyFiveMinutes()
        
    
    Schedule the event to run every five minutes.
        
                            $this
    everyTenMinutes()
        
    
    Schedule the event to run every ten minutes.
        
                            $this
    everyFifteenMinutes()
        
    
    Schedule the event to run every fifteen minutes.
        
                            $this
    everyThirtyMinutes()
        
    
    Schedule the event to run every thirty minutes.
        
                            $this
    hourly()
        
    
    Schedule the event to run hourly.
        
                            $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
    everyOddHour(array|string|int $offset = 0)
        
    
    Schedule the event to run every odd hour.
        
                            $this
    everyTwoHours(array|string|int $offset = 0)
        
    
    Schedule the event to run every two hours.
        
                            $this
    everyThreeHours(array|string|int $offset = 0)
        
    
    Schedule the event to run every three hours.
        
                            $this
    everyFourHours(array|string|int $offset = 0)
        
    
    Schedule the event to run every four hours.
        
                            $this
    everySixHours(array|string|int $offset = 0)
        
    
    Schedule the event to run every six hours.
        
                            $this
    daily()
        
    
    Schedule the event to run daily.
        
                            $this
    at(string $time)
        
    
    Schedule the command at a given time.
        
                            $this
    dailyAt(string $time)
        
    
    Schedule the event to run daily at a given time (10:00, 19:30, etc).
        
                            $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
    weekdays()
        
    
    Schedule the event to run only on weekdays.
        
                            $this
    weekends()
        
    
    Schedule the event to run only on weekends.
        
                            $this
    mondays()
        
    
    Schedule the event to run only on Mondays.
        
                            $this
    tuesdays()
        
    
    Schedule the event to run only on Tuesdays.
        
                            $this
    wednesdays()
        
    
    Schedule the event to run only on Wednesdays.
        
                            $this
    thursdays()
        
    
    Schedule the event to run only on Thursdays.
        
                            $this
    fridays()
        
    
    Schedule the event to run only on Fridays.
        
                            $this
    saturdays()
        
    
    Schedule the event to run only on Saturdays.
        
                            $this
    sundays()
        
    
    Schedule the event to run only on Sundays.
        
                            $this
    weekly()
        
    
    Schedule the event to run weekly.
        
                            $this
    weeklyOn(mixed $dayOfWeek, string $time = '0:0')
        
    
    Schedule the event to run weekly on a given day and time.
        
                            $this
    monthly()
        
    
    Schedule the event to run monthly.
        
                            $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
    lastDayOfMonth(string $time = '0:0')
        
    
    Schedule the event to run on the last day of the month.
        
                            $this
    quarterly()
        
    
    Schedule the event to run quarterly.
        
                            $this
    quarterlyOn(int $dayOfQuarter = 1, string $time = '0:0')
        
    
    Schedule the event to run quarterly on a given day and time.
        
                            $this
    yearly()
        
    
    Schedule the event to run yearly.
        
                            $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.
        
                            $this
    days(mixed $days)
        
    
    Set the days of the week the command should run on.
        
                            $this
    timezone(UnitEnum|DateTimeZone|string $timezone)
        
    
    Set the timezone the date should be evaluated on.
        
                    protected        $this
    spliceIntoPosition(int $position, string|int $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.
        
                            
    tap($callback = null)
        
    
    Call the given Closure with this instance then return the instance.
        
                            
    __construct(EventMutex $mutex, string|callable $callback, array $parameters = [], DateTimeZone|string|null $timezone = null)
        
    
    Create a new event instance.
        in 
Event at line 114
                            string
    getDefaultOutput()
        
    
    Get the default output depending on the OS.
        
                            void
    run(Container $container)
        
    
    Run the callback event.
        
                            bool
    shouldSkipDueToOverlapping()
        
    
    Determine if the event should skip because another process is overlapping.
        in 
Event at line 155
                            bool
    isRepeatable()
        
    
    Determine if the event has been configured to repeat multiple times per minute.
        in 
Event at line 165
                            bool
    shouldRepeatNow()
        
    
    Determine if the event is ready to repeat.
        in 
Event at line 179
                    protected        int
    start(Container $container)
        
    
    Run the command process.
        
                    protected        int
    execute(Container $container)
        
    
    Run the callback.
        in 
Event at line 216
                            void
    finish(Container $container, int $exitCode)
        
    
    Mark the command process as finished and run callbacks/cleanup.
        in 
Event at line 233
                            void
    callBeforeCallbacks(Container $container)
        
    
    Call all of the "before" callbacks for the event.
        in 
Event at line 246
                            void
    callAfterCallbacks(Container $container)
        
    
    Call all of the "after" callbacks for the event.
        in 
Event at line 258
                            string
    buildCommand()
        
    
    Build the command string.
        in 
Event at line 269
                            bool
    isDue(Application $app)
        
    
    Determine if the given event should run based on the Cron expression.
        in 
Event at line 284
                            bool
    runsInMaintenanceMode()
        
    
    Determine if the event runs in maintenance mode.
        in 
Event at line 294
                    protected        bool
    expressionPasses()
        
    
    Determine if the Cron expression passes.
        in 
Event at line 311
                            bool
    runsInEnvironment(string $environment)
        
    
    Determine if the event runs in the given environment.
        in 
Event at line 322
                            bool
    filtersPass(Application $app)
        
    
    Determine if the filters pass for the event.
        in 
Event at line 346
                            $this
    storeOutput()
        
    
    Ensure that the output is stored on disk in a log file.
        in 
Event at line 360
                            $this
    sendOutputTo(string $location, bool $append = false)
        
    
    Send the output of the command to a given location.
        in 
Event at line 375
                            $this
    appendOutputTo(string $location)
        
    
    Append the output of the command to a given location.
        in 
Event at line 389
                            $this
    emailOutputTo(mixed $addresses, bool $onlyIfOutputExists = true)
        
    
    E-mail the results of the scheduled operation.
        in 
Event at line 408
                            $this
    emailWrittenOutputTo(mixed $addresses)
        
    
    E-mail the results of the scheduled operation if it produces output.
        in 
Event at line 419
                            $this
    emailOutputOnFailure(mixed $addresses)
        
    
    E-mail the results of the scheduled operation if it fails.
        in 
Event at line 435
                    protected        void
    ensureOutputIsBeingCaptured()
        
    
    Ensure that the command output is being captured.
        in 
Event at line 450
                    protected        void
    emailOutput(Mailer $mailer, array $addresses, bool $onlyIfOutputExists = true)
        
    
    E-mail the output of the event to the recipients.
        in 
Event at line 468
                    protected        string
    getEmailSubject()
        
    
    Get the e-mail subject line for output results.
        in 
Event at line 483
                            $this
    pingBefore(string $url)
        
    
    Register a callback to ping a given URL before the job runs.
        in 
Event at line 495
                            $this
    pingBeforeIf(bool $value, string $url)
        
    
    Register a callback to ping a given URL before the job runs if the given condition is true.
        in 
Event at line 506
                            $this
    thenPing(string $url)
        
    
    Register a callback to ping a given URL after the job runs.
        in 
Event at line 518
                            $this
    thenPingIf(bool $value, string $url)
        
    
    Register a callback to ping a given URL after the job runs if the given condition is true.
        in 
Event at line 529
                            $this
    pingOnSuccess(string $url)
        
    
    Register a callback to ping a given URL if the operation succeeds.
        in 
Event at line 541
                            $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.
        in 
Event at line 552
                            $this
    pingOnFailure(string $url)
        
    
    Register a callback to ping a given URL if the operation fails.
        in 
Event at line 564
                            $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.
        in 
Event at line 575
                    protected        Closure
    pingCallback(string $url)
        
    
    Get the callback that pings the given URL.
        in 
Event at line 592
                    protected        ClientInterface
    getHttpClient(Container $container)
        
    
    Get the Guzzle HTTP client to use to send pings.
        in 
Event at line 611
                            $this
    before(Closure $callback)
        
    
    Register a callback to be called before the operation.
        in 
Event at line 624
                            $this
    after(Closure $callback)
        
    
    Register a callback to be called after the operation.
        in 
Event at line 635
                            $this
    then(Closure $callback)
        
    
    Register a callback to be called after the operation.
        in 
Event at line 655
                            $this
    thenWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
        
    
    Register a callback that uses the output after the job runs.
        in 
Event at line 668
                            $this
    onSuccess(Closure $callback)
        
    
    Register a callback to be called if the operation succeeds.
        in 
Event at line 690
                            $this
    onSuccessWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
        
    
    Register a callback that uses the output if the operation succeeds.
        in 
Event at line 703
                            $this
    onFailure(Closure $callback)
        
    
    Register a callback to be called if the operation fails.
        in 
Event at line 725
                            $this
    onFailureWithOutput(Closure $callback, bool $onlyIfOutputExists = false)
        
    
    Register a callback that uses the output if the operation fails.
        in 
Event at line 739
                    protected        Closure
    withOutputCallback(Closure $callback, bool $onlyIfOutputExists = false)
        
    
    Get a callback that provides output.
        
                            string
    getSummaryForDisplay()
        
    
    Get the summary of the event for display.
        in 
Event at line 772
                            Carbon
    nextRunDate(DateTimeInterface|string $currentTime = 'now', int $nth = 0, bool $allowCurrentDate = false)
        
    
    Determine the next due date for an event.
        in 
Event at line 783
                            string
    getExpression()
        
    
    Get the Cron expression for the event.
        in 
Event at line 794
                            $this
    preventOverlapsUsing(EventMutex $mutex)
        
    
    Set the event mutex implementation to be used.
        
                            string
    mutexName()
        
    
    Get the mutex name for the scheduled command.
        in 
Event at line 824
                            $this
    createMutexNameUsing(Closure|string $mutexName)
        
    
    Set the mutex name or name resolver callback.
        
                    protected        void
    removeMutex()
        
    
    Clear the mutex for the event.
        in 
Event at line 849
                static            string
    normalizeCommand(string $command)
        
    
    Format the given command string with a normalized PHP binary path.