QueueWorker class provides a simple interface to start and stop Laravel queue workers as persistent child processes in your NativePHP application.
Available Methods
up()
Start a queue worker process.Either a string alias referencing a queue worker configuration in your
config/nativephp.php file, or a QueueConfig object.config/nativephp.php under the queue_workers key.
down()
Stop a running queue worker process.The alias of the queue worker to stop.
Configuration
Queue workers are configured in yourconfig/nativephp.php file under the queue_workers key:
Configuration Options
An array of queue names that this worker should consume.
The memory limit in megabytes for the worker process.
The number of seconds a job can run before timing out.
The number of seconds to sleep when no job is available.
How It Works
Under the hood,QueueWorker uses the ChildProcess API to spawn persistent Artisan queue worker processes. The worker automatically:
- Uses
queue:listenin local environment andqueue:workin production - Runs as a persistent process that restarts automatically if it fails
- Sets appropriate memory limits for both the process and PHP
- Prefixes the process alias with
queue_to avoid conflicts