本文整理汇总了PHP中Queue::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::connection方法的具体用法?PHP Queue::connection怎么用?PHP Queue::connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::connection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
public function boot()
{
$this->package('orlissenberg/laravel-zendserver-pushqueue');
// 1. Need a route to marshal requests.
\Route::any("/queue/zendserver", function () {
/** @var ZendJobQueue $connection */
$connection = \Queue::connection("zendjobqueue");
$connection->marshal();
});
// 2. Add the connector to the Queue facade.
\Queue::addConnector("zendserver", function () {
return app()->make("\\Orlissenberg\\Queue\\Connectors\\ZendJobQueueConnector");
});
// 3. Add configuration to the app/config/queue.php
/*
'zendjob' => [
'driver' => 'zendserver',
'options' => [],
'callback-url' => '/queue/zendserver',
],
*/
// 4. Enable the test route (optional for testing only)
/*
\Route::get(
"/queue/zendtest",
function () {
$connection = \Queue::connection("zendjobqueue");
$connection->push("\\Orlissenberg\\Queue\\Handlers\\TestHandler@handle", ["laravel4" => "rocks"]);
return "Job queued.";
}
);
*/
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
* @throws Exception
*/
public function handle()
{
$user = User::findOrFail($this->argument('userId'));
if ($this->option('regenerate')) {
$albums = $user->albums;
} else {
$albums = $user->albums()->whereNull('thumbnailImageFileId')->get();
}
foreach ($albums as $album) {
\Queue::connection('sync')->push(new MakeAlbumThumbnailJob($album));
}
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
* @throws Exception
*/
public function handle()
{
$image = Image::findOrFail($this->argument('imageId'));
if (!empty($image->thumbnailImageFileId)) {
if (!$this->option('regenerate')) {
throw new Exception("Image already has a thumbnail and --regenerate was not set");
}
$thumbnail = $image->getThumbnailImageFile();
\Queue::connection('sync')->push(new DeleteFileJob($thumbnail->getPath()));
$thumbnail->delete(false);
}
\Queue::connection('sync')->push(new MakeThumbnailJob($image->getImageFile()));
}
示例4: getDriver
public function getDriver($alias)
{
try {
if ($alias == "Auth") {
$driver = \Auth::driver();
} elseif ($alias == "DB") {
$driver = \DB::connection();
} elseif ($alias == "Cache") {
$driver = \Cache::driver();
} elseif ($alias == "Queue") {
$driver = \Queue::connection();
} else {
return false;
}
return get_class($driver);
} catch (\Exception $e) {
$this->error("Could not determine driver/connection for {$alias}.");
return false;
}
}