class Listener

Properties

protected string $environment

The environment the workers should run under.

protected int $sleep

The amount of seconds to wait before polling the queue.

protected int $maxTries

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

protected Closure|null $outputHandler

The output handler callback.

Methods

__construct(string $commandPath)

Create a new queue listener.

string
phpBinary()

Get the PHP binary.

string
artisanBinary()

Get the Artisan binary.

void
listen(string|null $connection, string $queue, ListenerOptions $options)

Listen to the given queue connection.

Process
makeProcess(string|null $connection, string $queue, ListenerOptions $options)

Create a new Symfony process for the worker.

array
addEnvironment(array $command, ListenerOptions $options)

Add the environment option to the given command.

array
createCommand(string|null $connection, string $queue, ListenerOptions $options)

Create the command with the listener options.

void
runProcess(Process $process, float $memory)

Run the given process.

void
handleWorkerOutput(string $type, string $line)

Handle output from the worker process.

bool
memoryExceeded(float $memoryLimit)

Determine if the memory limit has been exceeded.

never
stop()

Stop listening and bail out of the script.

void
setOutputHandler(Closure $outputHandler)

Set the output handler callback.

Details

at line 38
__construct(string $commandPath)

Create a new queue listener.

Parameters

string $commandPath

at line 46
protected string phpBinary()

Get the PHP binary.

Return Value

string

at line 54
protected string artisanBinary()

Get the Artisan binary.

Return Value

string

at line 62
void listen(string|null $connection, string $queue, ListenerOptions $options)

Listen to the given queue connection.

Parameters

string|null $connection
string $queue
ListenerOptions $options

Return Value

void

at line 78
Process makeProcess(string|null $connection, string $queue, ListenerOptions $options)

Create a new Symfony process for the worker.

Parameters

string|null $connection
string $queue
ListenerOptions $options

Return Value

Process

at line 105
protected array addEnvironment(array $command, ListenerOptions $options)

Add the environment option to the given command.

Parameters

array $command
ListenerOptions $options

Return Value

array

at line 113
protected array createCommand(string|null $connection, string $queue, ListenerOptions $options)

Create the command with the listener options.

Parameters

string|null $connection
string $queue
ListenerOptions $options

Return Value

array

at line 136
void runProcess(Process $process, float $memory)

Run the given process.

Parameters

Process $process
float $memory

Return Value

void

at line 153
protected void handleWorkerOutput(string $type, string $line)

Handle output from the worker process.

Parameters

string $type
string $line

Return Value

void

at line 163
bool memoryExceeded(float $memoryLimit)

Determine if the memory limit has been exceeded.

Parameters

float $memoryLimit

Return Value

bool

at line 173
never stop()

Stop listening and bail out of the script.

Return Value

never

at line 184
void setOutputHandler(Closure $outputHandler)

Set the output handler callback.

Boot-only. The callback persists on the singleton listener for the command lifetime and handles every subsequent worker output line.

Parameters

Closure $outputHandler

Return Value

void