This library is a Queueing System abstraction layer. It enables you to implement any queueing system in your application, without having to depend on the actual implementation of the queueing system you choose.
Attention: You will need a Process Control System like supervisord to keep your workers going.
Say you want to notify multiple users when a new comment is placed on a forum thread. Sending these email on the spot might slow down your application significantly when many emails need to be send. When using a Queueing System you can delay this action by adding the Jobs to a Queue. A worker will pick up these Jobs asynchronously from you web process. This way your application is future proof and you will have a much easier time scaling in the future.
When you decide to use this library, you do not depend on the queueing system implementation. You can plug the driver of your choice. You might choose a basic mysql version to get started and when you need more performance go for something like beanstalkd or RabbitMQ.
<?php require_once(__DIR__ . '/vendor/autoload.php'); use Akop\Queue; use Akop\Job\Job; use Akop\Driver\PDO as Driver; // Use your driver. use Akop\Executor\JobExecutor; $driver = new Driver(); $queue = new Queue($driver); // Add a job to the queue $queue->addJob(new Job('notify_forum_thead', ['threadId' => 12]));
<?php use Akop\Queue; use Akop\Job\Job; use Akop\Driver\PDO as Driver; // Use your driver. use Akop\Executor\JobExecutor; $driver = new Driver(); $queue = new Queue($driver); $worker = new Worker($queue, new JobExecutor(), 1); $queue->run();
Run this command to get the latest version from packagist:
$ composer require aak74/queue
PHP 5.5 or above
Queue is licensed under the MIT license.