PHP code example of iron-io / iron_worker

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

    

iron-io / iron_worker example snippets




$worker = new \IronWorker\IronWorker();



$worker = new \IronWorker\IronWorker();


$worker = new \IronWorker\IronWorker(array(
    'token' => 'XXXXXXXXX',
    'project_id' => 'XXXXXXXXX'
));


$worker = new \IronWorker\IronWorker('iron.json');


echo "Hello PHP World!\n";


$payload = array()
$options = array('label' => 'label_name', 'cluster' => 'dedicated')
$task_id = $worker->postTask('HelloWorld', $payload, $options);


$options = array('label' => 'label_name', 'cluster' => 'default');
$task_id = $worker->postSchedule('HelloWorkerRuby', $options);


$task_id = $worker->postTask('HelloWorld');
$details = $worker->getTaskDetails($task_id);

echo $details->status; # prints 'queued', 'complete', 'error' etc.


$task_id = $worker->postTask('HelloWorld');
sleep(10);
$details = $worker->getTaskDetails($task_id);
# Check log only if task is finished.
if ($details->status != 'queued') {
    $log = $worker->getLog($task_id);
    echo $log; # prints "Hello PHP World!"
}


$payload = array(
    'key_one' => 'Helpful text',
    'key_two' => 2,
    'options' => array(
        'option 1',
        'option 2'
    )
);

$worker->postTask('HelloWorld', $payload);

$worker->postScheduleSimple('HelloWorld', $payload, 10)

$worker->postScheduleAdvanced('HelloWorld', $payload, time()+3*60, 2*60, null, 5);


$args = getArgs();

echo "Hello PHP World!\n";

print_r($args);


$options = array('priority' => 1);
# Run task with medium priority
$worker->postTask('HelloWorld', $payload, $options);
ruby
runtime 'php'
exec 'HelloWorld.php'