Documentation

Listener
in package

Table of Contents

$commandPath  : string
The command working path.
$environment  : string
The environment the workers should run under.
$maxTries  : int
The amount of times to try a job before logging it failed.
$outputHandler  : Closure|null
The output handler callback.
$sleep  : int
The amount of seconds to wait before polling the queue.
$workerCommand  : string
The queue worker command line.
__construct()  : void
Create a new queue listener.
listen()  : void
Listen to the given queue connection.
makeProcess()  : Process
Create a new Symfony process for the worker.
memoryExceeded()  : bool
Determine if the memory limit has been exceeded.
runProcess()  : void
Run the given process.
setOutputHandler()  : void
Set the output handler callback.
stop()  : void
Stop listening and bail out of the script.
addEnvironment()  : string
Add the environment option to the given command.
artisanBinary()  : string
Get the Artisan binary.
buildCommandTemplate()  : string
Build the environment specific worker command.
formatCommand()  : string
Format the given command with the listener options.
handleWorkerOutput()  : void
Handle output from the worker process.
phpBinary()  : string
Get the PHP binary.

Properties

$commandPath

The command working path.

protected string $commandPath

$environment

The environment the workers should run under.

protected string $environment

$maxTries

The amount of times to try a job before logging it failed.

protected int $maxTries = 0

$outputHandler

The output handler callback.

protected Closure|null $outputHandler

$sleep

The amount of seconds to wait before polling the queue.

protected int $sleep = 3

$workerCommand

The queue worker command line.

protected string $workerCommand

Methods

__construct()

Create a new queue listener.

public __construct(string $commandPath) : void
Parameters
$commandPath : string
Return values
void

listen()

Listen to the given queue connection.

public listen(string $connection, string $queue, ListenerOptions $options) : void
Parameters
$connection : string
$queue : string
$options : ListenerOptions
Return values
void

memoryExceeded()

Determine if the memory limit has been exceeded.

public memoryExceeded(int $memoryLimit) : bool
Parameters
$memoryLimit : int
Return values
bool

runProcess()

Run the given process.

public runProcess(Process $process, int $memory) : void
Parameters
$process : Process
$memory : int
Return values
void

setOutputHandler()

Set the output handler callback.

public setOutputHandler(Closure $outputHandler) : void
Parameters
$outputHandler : Closure
Return values
void

stop()

Stop listening and bail out of the script.

public stop() : void
Return values
void

addEnvironment()

Add the environment option to the given command.

protected addEnvironment(string $command, ListenerOptions $options) : string
Parameters
$command : string
$options : ListenerOptions
Return values
string

artisanBinary()

Get the Artisan binary.

protected artisanBinary() : string
Return values
string

buildCommandTemplate()

Build the environment specific worker command.

protected buildCommandTemplate() : string
Return values
string

formatCommand()

Format the given command with the listener options.

protected formatCommand(string $command, string $connection, string $queue, ListenerOptions $options) : string
Parameters
$command : string
$connection : string
$queue : string
$options : ListenerOptions
Return values
string

handleWorkerOutput()

Handle output from the worker process.

protected handleWorkerOutput(int $type, string $line) : void
Parameters
$type : int
$line : string
Return values
void

phpBinary()

Get the PHP binary.

protected phpBinary() : string
Return values
string

Search results