コード例 #1
0
 *
 * 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();
    });
    $queue->getContainer()->bind('IronMQ', function () {
        return new IronMQ();
コード例 #2
0
<?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();