PHP code example of fivesqrd / hive

1. Go to this page and download the library: Download fivesqrd/hive 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/ */

    

fivesqrd / hive example snippets




return [
    'table' => 'My-Table-Name',
    'aws' => [
        'version' => 'latest',
        'region'  => 'eu-west-1',
        'credentials' => [
            'key'    => 'my-key',
            'secret' => 'my-secret',
        ],
    ],
];

php vendor/fivesqrd/hive/scripts/CreateTable.php config.php


$job = Hive\Job::create(
    ['to' => '[email protected]', 'subject' => 'hello']
);

/* Run as soon as possible */
$result = $queue->add($job);

/* Receive 5 jobs and lock them for 300 seconds (FIFO) */
$jobs = $queue->receive(5, 300);

foreach ($jobs as $job) {

    $payload = $job->payload();

    /* Do the work */
    $jobId = $job->id();

    /* Mark job as done */
    $queue->done($job);
}

/* Receive 5 jobs and lock them for 300 seconds (FILO) */
$jobs = $queue->receive(5, 300, false);

foreach ($jobs as $job) {

    $subject = $job->payload('subject');

    /* Do the work */
    $jobId = $job->id();

    /* Mark job as done */
    $queue->done($job);
}

/* Access individual job attributes */
foreach ($items as $job) {
    echo "Job id: {$job->attribute('Id')}\n";
    echo "Status: {$job->attribute('Status')}\n";
    echo "Created on: {$job->attribute('Timestamp')}\n";
    echo "Scheduled for: {$job->attribute('Timeslot')}\n";
}

/* Dump all attrinutes */
foreach ($items as $job) {
    print_r($job->attributes());
}