PHP code example of daycry / queues

1. Go to this page and download the library: Download daycry/queues library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daycry / queues example snippets


use Daycry\Queues\Job;

$job = new Job();
$job = $job->setQueue('default')
    ->url('https://httpbin.org/post', [
            'verify' => false,
            'method' => 'post',
            'body' => ['param1' => 'p1'],
            'dataType' => 'json',
            'headers' => [
                'X-API-KEY' => '1234'
            ]
        )
    ->enqueue();


use Daycry\Queues\Job;

$job = new Job();
$job = $job->command('foo:bar')->enqueue('default');



use Daycry\Queues\Job;

$job = new Job();
$job->classes(\Tests\Support\Classes\Example::class, 'run', ['constructor' => 'Contructor', 'method' => ['param1' => 1, 'param2' => 2]])->enqueue('default');



use Daycry\Queues\Job;

$job = new Job();
$job->shell('ls')->enqueue('default');



$dateTimeObj= new DateTime('now');
$dateTimeObj->add(new DateInterval("PT1H"));

$job = new Job();
$job->shell('ls');
$job->scheduled($dateTimeObj);
$result = $job->enqueue('default');



$job->setCallback('https://httpbin.org/post', ['method' => 'post', 'headers' =>['X-API-KEY' => '1234']]);



use Daycry\Queues\Job;

$job = new Job();
$job->shell('ls')->setPriority(10)->setTtr(3600)->enqueue('default');



use Daycry\Queues\Job;

$job = new Job();
$job->shell('ls')->setLabel('label')->enqueue('default');


use Daycry\Queues\Job;

$this->earlyChecks(Job $j);

//job execution

$this->lateChecks($j);

$this->earlyCallbackChecks(Job $j);

//callback execution

$this->lateCallbackChecks($j);