Created
February 7, 2019 07:38
-
-
Save lav45/295b0cce731875095d5de85c05696eff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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