Skip to content

Instantly share code, notes, and snippets.

@lav45
Created February 7, 2019 07:38
Show Gist options
  • Save lav45/295b0cce731875095d5de85c05696eff to your computer and use it in GitHub Desktop.
Save lav45/295b0cce731875095d5de85c05696eff to your computer and use it in GitHub Desktop.
<?php
class DownloadJob implements \yii\queue\JobInterface
{
public $url;
public $file;
public function execute($queue)
{
file_put_contents($this->file, file_get_contents($this->url));
}
}
$job = new DownloadJob();
$job->url = 'http://example.com/image.jpg';
$job->file = '/tmp/image.jpg';
$id = \Queue::i()
->date(strtotime('+1 day')) // будет выполнена через 1 день
->thread(2) // приоритет
->push($job);
// Cron
* * * * * cli queue run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment