1. Go to this page and download the library: Download huuuk/phalcon-queues library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
huuuk / phalcon-queues example snippets
use Huuuk\Queues\QueueManager;
// other services
$queueManager = new QueueManager($config);
$di->set('queue', $queueManager->getQueue());
class QueueTask extends \Huuuk\Queues\QueueTask
{
}
// where di it's your DI instance
$di->getQueue()->push(function() {
// do yuor magic
});
// where di it's your DI instance
$di->getQueue()->push(function($di) {
$di->getMailer()->send($address);
});
use Huuuk\Queues\Job;
class SendMail extends Job
{
protected $address;
function __construct($address)
{
$this->$address = $address;
}
public function handle()
{
// Place here yor logic
// to access DI, call
// $this->getDi();
$this->getDi()->getMailer()->send($this->address);
}
}
$user = User::findFirstById($id);
$job = new SendMail($user->email);
$di->getQueue()->push($job);
$di->getQueue()->push(new SimpleJob, null, 30); // no earlier than 30 seconds
$di->getQueue()->push(new SenDMail, 'mail', 60*60); // no earlier than 30 seconds an hour
$di->getQueue()->push(new ImageResize, 'images'); // as soon as worker will be run
bash
php app/cli queue help
bash
php app/cli queue dbtable --create
# for a bit more info run
# php app/cli queue --help
bash
php app/cli queue work
bash
php app/cli queue help
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.