You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

Event

Uses

Properties

public

$command string|null

The command string.

Default: null
public

$expression string

The cron expression representing the event's frequency.

Default: '* * * * *'
public

$repeatSeconds int|null

How often to repeat the event during a minute.

Default: null
public

$timezone DateTimeZone |string

The timezone the date should be evaluated on.

Default: null
public

$user string|null

The user the command should run as.

Default: null
public

$environments array

The list of environments the command should run under.

Default: []
public

$evenInMaintenanceMode bool

Indicates if the command should run in maintenance mode.

Default: false
public

$withoutOverlapping bool

Indicates if the command should not overlap itself.

Default: false
public

$onOneServer bool

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

Default: false
public

$expiresAt int

The number of minutes the mutex should be valid.

Default: 1440
public

$runInBackground bool

Indicates if the command should run in the background.

Default: false
protected

$filters array

The array of filter callbacks.

Default: []
protected

$rejects array

The array of reject callbacks.

Default: []
public

$output string

The location that output should be sent to.

Default: '/dev/null'
public

$shouldAppendOutput bool

Indicates whether output should be appended.

Default: false
protected

$beforeCallbacks array

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

Default: []
protected

$afterCallbacks array

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

Default: []
public

$description string|null

The human readable description of the event.

Default: null
public

$mutex EventMutex

The event mutex implementation.

Default: null
public

$mutexNameResolver Closure |null

The mutex name resolver callback.

Default: null
protected

$lastChecked Carbon |null

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

Utilized by sub-minute repeated events.

Default: null
public

$exitCode int|null

The exit status code of the command.

Default: null

Methods

public

__construct ( EventMutex $mutex , $command , $timezone ) : void

Create a new event instance.

Parameters

public

getDefaultOutput ( ) : string

Get the default output depending on the OS.

public

run ( Container $container ) : void

Run the given event.

Parameters

public

shouldSkipDueToOverlapping ( ) : bool

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

public

isRepeatable ( ) : bool

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

public

shouldRepeatNow ( ) : bool

Determine if the event is ready to repeat.

protected

start ( $container ) : int

Run the command process.

Parameters

protected

execute ( $container ) : int

Run the command process.

Parameters

public

finish ( Container $container , $exitCode ) : void

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

Parameters

public

callBeforeCallbacks ( Container $container ) : void

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

Parameters

public

callAfterCallbacks ( Container $container ) : void

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

Parameters

public

buildCommand ( ) : string

Build the command string.

public

isDue ( $app ) : bool

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

Parameters

public

runsInMaintenanceMode ( ) : bool

Determine if the event runs in maintenance mode.

protected

expressionPasses ( ) : bool

Determine if the Cron expression passes.

public

runsInEnvironment ( $environment ) : bool

Determine if the event runs in the given environment.

Parameters

  • $environment string
public

filtersPass ( $app ) : bool

Determine if the filters pass for the event.

Parameters

public

storeOutput ( ) : $this

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

public

sendOutputTo ( $location , $append ) : $this

Send the output of the command to a given location.

Parameters

  • $location string
  • $append bool
public

appendOutputTo ( $location ) : $this

Append the output of the command to a given location.

Parameters

  • $location string
public

emailOutputTo ( $addresses , $onlyIfOutputExists ) : $this

E-mail the results of the scheduled operation.

Parameters

  • $addresses array|mixed
  • $onlyIfOutputExists bool
public

emailWrittenOutputTo ( $addresses ) : $this

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

Parameters

  • $addresses array|mixed
public

emailOutputOnFailure ( $addresses ) : $this

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

Parameters

  • $addresses array|mixed
protected

ensureOutputIsBeingCaptured ( ) : void

Ensure that the command output is being captured.

protected

emailOutput ( Mailer $mailer , $addresses , $onlyIfOutputExists ) : void

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

Parameters

  • $mailer Mailer
  • $addresses array
  • $onlyIfOutputExists bool
protected

getEmailSubject ( ) : string

Get the e-mail subject line for output results.

public

pingBefore ( $url ) : $this

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

Parameters

  • $url string
public

pingBeforeIf ( $value , $url ) : $this

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

Parameters

  • $value bool
  • $url string
public

thenPing ( $url ) : $this

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

Parameters

  • $url string
public

thenPingIf ( $value , $url ) : $this

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

Parameters

  • $value bool
  • $url string
public

pingOnSuccess ( $url ) : $this

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

Parameters

  • $url string
public

pingOnFailure ( $url ) : $this

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

Parameters

  • $url string
protected

pingCallback ( $url ) : Closure

Get the callback that pings the given URL.

Parameters

  • $url string
protected

getHttpClient ( Container $container ) : GuzzleHttp\ClientInterface

Get the Guzzle HTTP client to use to send pings.

Parameters

public

runInBackground ( ) : $this

State that the command should run in the background.

public

user ( $user ) : $this

Set which user the command should run as.

Parameters

  • $user string
public

environments ( $environments ) : $this

Limit the environments the command should run in.

Parameters

  • $environments array|mixed
public

evenInMaintenanceMode ( ) : $this

State that the command should run even in maintenance mode.

public

withoutOverlapping ( $expiresAt ) : $this

Do not allow the event to overlap each other.

Parameters

  • $expiresAt int
public

onOneServer ( ) : $this

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

public

when ( $callback ) : $this

Register a callback to further filter the schedule.

Parameters

public

skip ( $callback ) : $this

Register a callback to further filter the schedule.

Parameters

public

before ( Closure $callback ) : $this

Register a callback to be called before the operation.

Parameters

public

after ( Closure $callback ) : $this

Register a callback to be called after the operation.

Parameters

public

then ( Closure $callback ) : $this

Register a callback to be called after the operation.

Parameters

public

thenWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this

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

Parameters

  • $callback Closure
  • $onlyIfOutputExists bool
public

onSuccess ( Closure $callback ) : $this

Register a callback to be called if the operation succeeds.

Parameters

public

onSuccessWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this

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

Parameters

  • $callback Closure
  • $onlyIfOutputExists bool
public

onFailure ( Closure $callback ) : $this

Register a callback to be called if the operation fails.

Parameters

public

onFailureWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this

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

Parameters

  • $callback Closure
  • $onlyIfOutputExists bool
protected

withOutputCallback ( Closure $callback , $onlyIfOutputExists ) : Closure

Get a callback that provides output.

Parameters

  • $callback Closure
  • $onlyIfOutputExists bool
public

name ( $description ) : $this

Set the human-friendly description of the event.

Parameters

  • $description string
public

description ( $description ) : $this

Set the human-friendly description of the event.

Parameters

  • $description string
public

getSummaryForDisplay ( ) : string

Get the summary of the event for display.

public

nextRunDate ( $currentTime , $nth , $allowCurrentDate ) : Carbon

Determine the next due date for an event.

Parameters

public

getExpression ( ) : string

Get the Cron expression for the event.

public

preventOverlapsUsing ( EventMutex $mutex ) : $this

Set the event mutex implementation to be used.

Parameters

public

mutexName ( ) : string

Get the mutex name for the scheduled command.

public

createMutexNameUsing ( $mutexName ) : $this

Set the mutex name or name resolver callback.

Parameters

protected

removeMutex ( ) : void

Delete the mutex for the event.