Example #1
0
 *           illuminate/http/request (if using iron.io, others? unsure?)
 *           iron-io/iron_mq (if using iron.io)
 *
 * Note: Laravel's queue driver is for pushing Closures and classes up to
 *       a queue, and then pulling them back down and operating on them.
 *       Unlike other queue drivers, there is no focus on pushing just strings,
 *       arrays, or objects for use by other programs or languages.
 *
 * @source https://github.com/illuminate/queue
 * @see http://safeerahmed.uk/illuminate-queues-everywhere-laravel-4-queues-component
 */
$app = new \Slim\Slim();
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
date_default_timezone_set('UTC');
// BOOTSTRAP-------------------------------------------------------------------
$queue = new Queue();
// Make this Capsule instance available globally via static methods... (optional)
$queue->setAsGlobal();
$queue->getContainer()->bind('encrypter', function () {
    return new Illuminate\Encryption\Encrypter('foobar');
});
// END BOOTSTRAP---------------------------------------------------------------
$app->get('/sync', function () use($queue) {
    $queue->addConnection(['driver' => 'sync']);
    Queue::push('doThing', array('string' => 'sync-' . date('r')));
    echo 'Pushed an instance of doThing to sync driver.';
});
$app->get('/ironio/add', function () use($queue) {
    $queue->getContainer()->bind('request', function () {
        return new Illuminate\Http\Request();
    });
Example #2
0
 /**
  * Push a new job onto the queue after a delay.
  *
  * @param  \DateTime|int  $delay
  * @param  string  $job
  * @param  mixed   $data
  * @param  string  $queue
  * @param  string  $connection
  * @return mixed
  */
 public static function later($delay, $job, $data = '', $queue = null, $connection = null)
 {
     return static::$instance->connection($connection)->later($delay, $job, $data, $queue);
 }
Example #3
0
 /**
  * Push a new job onto the queue after a delay.
  *
  * @param  \DateTime|int $delay
  * @param  string $job
  * @param  mixed $data
  * @param  string $queue
  * @param  string $connection
  * @return mixed
  */
 public static function later($delay, $job, $data = '', $queue = null, $connection = null)
 {
     Manager::later($delay, $job, $data, $queue, $connection);
 }
<?php

require_once __DIR__ . "/../autoload.php";
use Orlissenberg\Queue\ZendJobQueue;
use Illuminate\Queue\Capsule\Manager as Capsule;
/** @var ZendJobQueue $queue */
$queue = Capsule::connection("zend");
$queue->push("\\Orlissenberg\\Queue\\Handlers\\TestHandler@handle", ["test" => "data"], null);
$queue->push(function () {
    $handle = fopen("test.log", "a");
    if ($handle) {
        fwrite($handle, "Oh look it's a super closure.");
        fclose($handle);
    }
}, ["test" => "this should work too"]);
echo 'Jobs queued up!';
<?php

require_once __DIR__ . "/vendor/autoload.php";
use Illuminate\Http\Request;
use Illuminate\Queue\Capsule\Manager as Capsule;
use Orlissenberg\Queue\Connectors\ZendJobQueueConnector;
$capsule = new Capsule();
/** @var \Illuminate\Queue\QueueManager $manager */
$manager = $capsule->getQueueManager();
$app = $capsule->getContainer();
$app->bind("encrypter", function () {
    return new Illuminate\Encryption\Encrypter("test");
});
$app->bind("request", function () {
    return Request::createFromGlobals();
});
// Add a new connector
$manager->extend("zendserver", function () use($app) {
    return new ZendJobQueueConnector($app['encrypter'], $app['request']);
});
// Add a connection by the name of "zend"
$capsule->addConnection(['driver' => 'zendserver', 'options' => [], 'callback-url' => 'http://jobqueue.dev/tests/receive.php'], 'zend');
// A driver requires configuration?
$capsule->setAsGlobal();