PHP code example of zer0-framework / queue
1. Go to this page and download the library: Download zer0-framework/queue 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/ */
zer0-framework / queue example snippets
$pool = $this->app->factory('Queue');
try {
var_dump($pool->enqueueWait(new SomeTask(), /* ждём ответа */ 3 /* секунды */)->foo);
// string(3) "bar"
} catch (\Zer0\Queue\Exceptions\WaitTimeoutException $e) {
// Задача не завершилась за 3 секунды
}
final class SomeTask extends \Zer0\Queue\TaskAbstract
{
/**
* @var string
*/
public $foo;
/**
*
*/
public function execute(): void
{
$this->foo = 'bar';
$this->complete();
}
}