The CakePHP Enqueue plugin provides message queue integration for CakePHP applications and uses database as a message broker.
- Install the plugin:
composer require cakedc/cakephp-enqueue- Load the plugin in your
Application.php:
$this->addPlugin('CakephpEnqueue');- Configure your queue in
config/app.php:
'Queue' => [
'default' => [
'url' => 'cakephp://default?table_name=queue'
]
]- Create a job:
use App\Job\ExampleJob;
use Cake\Queue\QueueManager;
$data = ['id' => 7, 'is_premium' => true];
$options = ['config' => 'default'];
QueueManager::push(ExampleJob::class, $data, $options);- Process jobs:
bin/cake queue:workerThe plugin supports standard DSN format:
cakephp://connection_name?table_name=queue&polling_interval=1000