Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PHP examples moved to separate directories. Library updated.

  • Loading branch information...
commit a76ed534cb5e071b8931786eb2402b2bc0ad49b5 1 parent 217ee69
@thousandsofthem authored
Showing with 298 additions and 471 deletions.
  1. +2 −0  .gitignore
  2. +0 −13 php/Airbrake.php
  3. +0 −32 php/Basic.php
  4. +0 −29 php/BasicShedule.php
  5. +0 −18 php/BasicSimplest.php
  6. +0 −20 php/FFmpeg.php
  7. +0 −26 php/FFmpegFlv.php
  8. +0 −110 php/Full.php
  9. +0 −16 php/Loggly.php
  10. +0 −28 php/Mongo.php
  11. +0 −19 php/Mysql.php
  12. +0 −27 php/PDO.php
  13. +0 −15 php/PagerDuty.php
  14. +0 −23 php/PharZend.php
  15. +6 −6 php/README.md
  16. +0 −19 php/Redis.php
  17. +0 −24 php/Twitter.php
  18. +10 −0 php/airbrake/enqueue.php
  19. +8 −0 php/airbrake/upload.php
  20. 0  php/{workers/airbrake → airbrake/worker}/airbrake.php
  21. 0  php/{workers/airbrake → airbrake/worker}/lib/Airbrake.class.php
  22. +6 −12 php/{BatchEmailer.php → batch_emailer/enqueue.php}
  23. +10 −0 php/batch_emailer/upload.php
  24. 0  php/{workers/batch_emailer → batch_emailer/worker}/contents.html
  25. 0  php/{workers/batch_emailer → batch_emailer/worker}/images/phpmailer.gif
  26. 0  php/{workers/batch_emailer → batch_emailer/worker}/images/phpmailer_mini.gif
  27. 0  php/{workers/batch_emailer → batch_emailer/worker}/lib/class.phpmailer.php
  28. 0  php/{workers/batch_emailer → batch_emailer/worker}/lib/class.pop3.php
  29. 0  php/{workers/batch_emailer → batch_emailer/worker}/lib/class.smtp.php
  30. 0  php/{workers/batch_emailer → batch_emailer/worker}/sendEmail.php
  31. 0  php/code/.gitkeep
  32. +8 −13 php/{GD_S3.php → draw_gd_and_upload_to_s3/enqueue.php}
  33. +7 −0 php/draw_gd_and_upload_to_s3/upload.php
  34. 0  php/{workers/draw_gd_and_upload_to_s3 → draw_gd_and_upload_to_s3/worker}/font/Ubuntu-R.ttf
  35. +1 −2  php/{workers/draw_gd_and_upload_to_s3 → draw_gd_and_upload_to_s3/worker}/gd_s3.php
  36. 0  php/{workers/draw_gd_and_upload_to_s3 → draw_gd_and_upload_to_s3/worker}/lib/S3.php
  37. +17 −0 php/ffmpeg_flv/enqueue.php
  38. +6 −0 php/ffmpeg_flv/upload.php
  39. 0  php/{workers/ffmpeg_flv → ffmpeg_flv/worker}/ffmpeg.php
  40. 0  php/{workers/ffmpeg_flv → ffmpeg_flv/worker}/functions.php
  41. +14 −0 php/ffmpeg_frames/enqueue.php
  42. +6 −0 php/ffmpeg_frames/upload.php
  43. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/ffmpeg.php
  44. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame0.gif
  45. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame1.gif
  46. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame10.gif
  47. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame11.gif
  48. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame12.gif
  49. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame13.gif
  50. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame2.gif
  51. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame3.gif
  52. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame4.gif
  53. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame5.gif
  54. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame6.gif
  55. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame7.gif
  56. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame8.gif
  57. 0  php/{workers/ffmpeg → ffmpeg_frames/worker}/frames/Frame9.gif
  58. +1 −2  php/hello_worker/enqueue.php
  59. +1 −2  php/hello_worker/upload.php
  60. +12 −0 php/loggly/enqueue.php
  61. +6 −0 php/loggly/upload.php
  62. 0  php/{workers/loggly → loggly/worker}/loggly.php
  63. +18 −0 php/mongo/enqueue.php
  64. +6 −0 php/mongo/upload.php
  65. 0  php/{workers/mongo → mongo/worker}/mongo.php
  66. +14 −0 php/mysql/enqueue.php
  67. +6 −0 php/mysql/upload.php
  68. 0  php/{workers/mysql → mysql/worker}/config.ini
  69. 0  php/{workers/mysql → mysql/worker}/testMysql.php
  70. +12 −0 php/pager_duty/enqueue.php
  71. +8 −0 php/pager_duty/upload.php
  72. 0  php/{workers/pager_duty → pager_duty/worker}/pagerDuty.php
  73. +21 −0 php/pdo/enqueue.php
  74. +6 −0 php/pdo/upload.php
  75. 0  php/{workers/PDO → pdo/worker}/Pdo.php
  76. +8 −0 php/phar_zend/enqueue.php
  77. +6 −0 php/phar_zend/upload.php
  78. 0  php/{workers/phar_zend_lib → phar_zend/worker}/pharZend.php
  79. 0  php/{workers/phar_zend_lib → phar_zend/worker}/zend/zf_1_11_0.phar.gz
  80. +8 −0 php/redis/enqueue.php
  81. +8 −0 php/redis/upload.php
  82. 0  php/{workers/php_redis → redis/worker}/lib/redis.peer.php
  83. 0  php/{workers/php_redis → redis/worker}/lib/redis.php
  84. 0  php/{workers/php_redis → redis/worker}/lib/redis.pool.php
  85. 0  php/{workers/php_redis → redis/worker}/lib/redis_list.peer.php
  86. 0  php/{workers/php_redis → redis/worker}/lib/redis_set.peer.php
  87. 0  php/{workers/php_redis → redis/worker}/testRedis.php
  88. +21 −0 php/scheduling/schedule.php
  89. +6 −0 php/scheduling/upload.php
  90. +3 −0  php/scheduling/worker/worker.php
  91. +18 −0 php/twitter/enqueue.php
  92. +8 −0 php/twitter/upload.php
  93. 0  php/{workers/post_to_twitter → twitter/worker}/config.ini
  94. 0  php/{workers/post_to_twitter → twitter/worker}/lib/OAuth.php
  95. 0  php/{workers/post_to_twitter → twitter/worker}/lib/TwitterOAuth.php
  96. 0  php/{workers/post_to_twitter → twitter/worker}/postToTwitter.php
  97. +0 −12 php/workers/hello_world/testTask.php
  98. +0 −3  php/workers/hello_world_simple/testTaskSimple.php
View
2  .gitignore
@@ -3,4 +3,6 @@
/config.ini
*.log
/php/code/*.zip
+/IronCore.class.php
/IronWorker.class.php
+/iron_worker.phar
View
13 php/Airbrake.php
@@ -1,13 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "airbrake-php";
-
-$iw = new IronWorker('config.ini');
-$iw->debug_enabled = true;
-
-$iw->upload(dirname(__FILE__)."/workers/airbrake", 'airbrake.php', $name);
-
-$payload = array('api_key' => AIRBRAKE_API_KEY);
-
-$iw->postTask($name, $payload);
View
32 php/Basic.php
@@ -1,32 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testBasic-php";
-
-$iw = new IronWorker('config.ini');
-
-$iw->upload(dirname(__FILE__)."/workers/hello_world", 'testTask.php', $name);
-
-$payload = array(
- 'key_one' => 'Helpful text',
- 'key_two' => 2,
- 'options' => array(
- 'option 1',
- 'option 2',
- 'option 3',
- 'option 4',
- 'option five'
- )
-);
-
-$task_id = $iw->postTask($name, $payload);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-$log = $iw->getLog($task_id);
-echo $log;
-
-
-
View
29 php/BasicShedule.php
@@ -1,29 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testBasic-Schedule-php";
-
-$iw = new IronWorker('config.ini');
-
-$iw->upload(dirname(__FILE__)."/workers/hello_world", 'testTask.php', $name);
-
-$payload = array(
- 'key_one' => 'Payload',
- 'key_two' => 2
-);
-
-# 3 minutes later
-$start_at = time()+3*60;
-
-# Run task every 2 minutes 10 times
-$schedule_id = $iw->postScheduleAdvanced($name, $payload, $start_at, 2*60, null, 10);
-
-# Get schedule information
-$schedule = $iw->getSchedule($schedule_id);
-echo "Schedule:\n";
-print_r($schedule);
-
-echo "\ndone\n";
-
-
-
View
18 php/BasicSimplest.php
@@ -1,18 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testTaskSimple-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/hello_world_simple", 'testTaskSimple.php', $name);
-
-# Adding new task.
-$task_id = $iw->postTask($name);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-
View
20 php/FFmpeg.php
@@ -1,20 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testFFmpeg-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/ffmpeg", 'ffmpeg.php', $name);
-
-# Adding new task.
-$task_id = $iw->postTask($name);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-# Get task log
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
View
26 php/FFmpegFlv.php
@@ -1,26 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testFFmpeg-flv-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/ffmpeg_flv", 'ffmpeg.php', $name);
-
-# Adding new task.
-$payload = array(
- 'input_file' => 'https://s3.amazonaws.com/iron-examples/video/iron_man_2_trailer_official.flv'
-);
-$task_id = $iw->postTask($name, $payload);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-echo "Status: {$details->status}\n";
-
-# Get task log
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
-
-
View
110 php/Full.php
@@ -1,110 +0,0 @@
-<?php
-include_once("../IronWorker.class.php");
-
-
-function tolog($name, $variable, $display = false){
- file_put_contents("log_{$name}.log", print_r($variable, true));
- if ($display){echo "{$name}: ".var_export($variable,true)."\n";}
-}
-
-$name = "testFull-php";
-
-$iw = new IronWorker('config.ini');
-$iw->debug_enabled = true;
-
-
-# ========================== Projects ===========================
-
-echo "\n--Get Project List------------------------------------\n";
-$projects = $iw->getProjects();
-tolog('projects', $projects);
-
-echo "\n--Get Project Details---------------------------------\n";
-$project_details = $iw->getProjectDetails();
-tolog('project_details', $project_details);
-
-# =========================== Codes =============================
-
-echo "\n--Posting Code----------------------------------------\n";
-$zipName = "code/$name.zip";
-$files_to_zip = array('testTask.php');
-# if true, good; if false, zip creation failed
-$zipFile = IronWorker::createZip(dirname(__FILE__)."/workers/hello_world", $files_to_zip, $zipName, true);
-if (!$zipFile) die("Zip file $zipName was not created!");
-
-$res = $iw->postCode('testTask.php', $zipName, $name);
-tolog('post_code', $res);
-
-echo "\n--Get Codes-------------------------------------------\n";
-$codes = $iw->getCodes();
-tolog('codes', $codes);
-
-echo "\n-Get Code Details--------------------------------------\n";
-$code_details = $iw->getCodeDetails($codes[0]->id);
-tolog('get_code_details', $code_details);
-
-# =========================== Tasks =============================
-
-echo "\n--Get Tasks-------------------------------------------\n";
-$tasks = $iw->getTasks();
-tolog('tasks', $tasks);
-
-echo "\n--Posting Task----------------------------------------\n";
-$task_id = $iw->postTask($name);
-tolog('post_task', $task_id, true);
-
-echo "\n--Wait For Task----------------------------------------\n";
-$details = $iw->waitFor($task_id);
-tolog('wait_for', $details, true);
-
-echo "\n--Get Task Details------------------------------------\n";
-$details = $iw->getTaskDetails($task_id);
-tolog('task_details', $details, true);
-
-echo "\n--Get Task Log----------------------------------------\n";
-sleep(15);
-# Check log only if task finished.
-if ($details->status != 'queued'){
- $log = $iw->getLog($task_id);
- tolog('task_log', $log, true);
-}
-
-echo "\n--Set Task Progress-----------------------------------\n";
-$res = $iw->setTaskProgress($task_id, 50, 'Job half-done');
-tolog('set_task_progress', $res, true);
-
-echo "\n--Deleting Task---------------------------------------\n";
-$res = $iw->deleteTask($task_id);
-tolog('delete_task', $res, true);
-
-# ========================== Schedules ==========================
-
-echo "\n--Posting Simple Shedule--------------------------------------\n";
-$schedule_id = $iw->postScheduleSimple($name, 10);
-tolog('post_schedule_simple', $schedule_id, true);
-
-echo "\n--Posting Advanced Shedule--------------------------------------\n";
-$schedule_id = $iw->postScheduleAdvanced($name, array(), time()+2*60, 50, null, 4, 0);
-tolog('post_schedule_advanced', $schedule_id, true);
-
-echo "\n--Get Schedules----------------------------------------\n";
-$schedules = $iw->getSchedules();
-tolog('schedules', $schedules);
-
-echo "\n--Get Schedule----------------------------------------\n";
-$schedule = $iw->getSchedule($schedule_id);
-tolog('schedule', $schedule);
-
-echo "\n--Deleting Shedule-------------------------------------\n";
-$res = $iw->deleteSchedule($schedule_id);
-tolog('delete_schedule', $res, true);
-
-
-
-
-
-
-
-
-
-echo "\ndone\n";
View
16 php/Loggly.php
@@ -1,16 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "loggly-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/loggly", 'loggly.php', $name);
-
-for ($i = 1; $i <= 50; $i++)
-{
- $payload = array('api_key' => LOGGLY_KEY, 'i' => $i);
-
- $iw->postTask($name, $payload);
-}
View
28 php/Mongo.php
@@ -1,28 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testMongo-php";
-
-$config = parse_ini_file('../config.ini', true);
-
-$iw = new IronWorker($config['iron_worker']);
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/mongo", 'mongo.php', $name);
-
-$payload = array(
- 'db' => $config['mongo']
-);
-
-$task_id = $iw->postTask($name, $payload);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-# Check log
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
-
-
View
19 php/Mysql.php
@@ -1,19 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testMysql.php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/mysql", 'testMysql.php', $name);
-
-$task_id = $iw->postTask($name);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
View
27 php/PDO.php
@@ -1,27 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testPDO.php";
-
-$config = parse_ini_file('../config.ini', true);
-
-# Passing array of options instead of config file.
-$iw = new IronWorker($config['iron_worker']);
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/PDO", 'Pdo.php', $name);
-
-$payload = array(
- 'connection' => $config['pdo'],
- 'yet_another' => array('value', 'value #2')
-);
-
-$task_id = $iw->postTask($name, $payload);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
View
15 php/PagerDuty.php
@@ -1,15 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "pagerDuty-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/pager_duty", 'pagerDuty.php', $name);
-
-$payload = array(
- 'API_KEY' => PAGERDUTY_API_KEY
-);
-
-$iw->postTask($name, $payload);
View
23 php/PharZend.php
@@ -1,23 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testPharZend-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/phar_zend_lib", 'pharZend.php', $name);
-
-$task_id = $iw->postTask($name);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-# Check log
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
-
-
-
View
12 php/README.md
@@ -1,12 +1,12 @@
All PHP examples uses [IronWorker PHP library](https://github.com/iron-io/iron_worker_php)
-To start using examples just copy `IronWorker.class.php` to parent folder and create `config.ini` with credentials:
+To start using examples just copy `iron_worker.phar` to this folder and create `iron.json` with credentials:
-```ini
-[iron_worker]
-token = XXXXXXXXXXXX
-project_id = XXXXXXXXXXXX
+```json
+{
+ "token": "XXXXXXXXXXXX",
+ "project_id": "XXXXXXXXXXXX"
+}
```
-Then simply run an example: `php Basic.php`
For more information, please read [iron_worker_php](https://github.com/iron-io/iron_worker_php) readme.
View
19 php/Redis.php
@@ -1,19 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "testRedis-PHP";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/php_redis", 'testRedis.php', $name);
-
-$task_id = $iw->postTask($name);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
View
24 php/Twitter.php
@@ -1,24 +0,0 @@
-<?php
-include("../IronWorker.class.php");
-
-$name = "postToTwitter-php";
-
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/post_to_twitter", 'postToTwitter.php', $name);
-
-$payload = array(
- 'message' => "Hello From PHPWorker at ".date('r')."!\n",
- 'url' => 'http://www.iron.io/'
-);
-
-$task_id = $iw->postTask($name, $payload);
-
-# Wait for task finish
-$details = $iw->waitFor($task_id);
-print_r($details);
-
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
View
10 php/airbrake/enqueue.php
@@ -0,0 +1,10 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$payload = array('api_key' => AIRBRAKE_API_KEY);
+
+$worker->postTask("AirBrake", $payload);
+
View
8 php/airbrake/upload.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->upload("worker/", 'airbrake.php', "AirBrake");
+
View
0  php/workers/airbrake/airbrake.php → php/airbrake/worker/airbrake.php
File renamed without changes
View
0  php/workers/airbrake/lib/Airbrake.class.php → php/airbrake/worker/lib/Airbrake.class.php
File renamed without changes
View
18 php/BatchEmailer.php → php/batch_emailer/enqueue.php
@@ -1,11 +1,7 @@
<?php
-include("../IronWorker.class.php");
+require_once "phar://../iron_worker.phar";
-$name = "sendEmail-php";
-
-$iw = new IronWorker('config.ini');
-
-$iw->upload(dirname(__FILE__)."/workers/batch_emailer", 'sendEmail.php', $name);
+$worker = new IronWorker();
$payload = array(
'address' => "",
@@ -26,15 +22,13 @@
$payload['address'] = "name_$i@example.com";
$payload['name'] = "Dear Friend $i";
- $task_id = $iw->postTask($name, $payload);
+ $task_id = $worker->postTask("sendEmail-php", $payload);
echo "task_id = $task_id \n";
# Wait for task finish
- $details = $iw->waitFor($task_id);
+ $details = $worker->waitFor($task_id);
print_r($details);
- $log = $iw->getLog($task_id);
+ $log = $worker->getLog($task_id);
echo "Task log:\n $log\n";
-}
-
-
+}
View
10 php/batch_emailer/upload.php
@@ -0,0 +1,10 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'sendEmail.php', "sendEmail-php");
+
+
+
+
View
0  php/workers/batch_emailer/contents.html → php/batch_emailer/worker/contents.html
File renamed without changes
View
0  php/workers/batch_emailer/images/phpmailer.gif → php/batch_emailer/worker/images/phpmailer.gif
File renamed without changes
View
0  php/workers/batch_emailer/images/phpmailer_mini.gif → php/batch_emailer/worker/images/phpmailer_mini.gif
File renamed without changes
View
0  php/workers/batch_emailer/lib/class.phpmailer.php → php/batch_emailer/worker/lib/class.phpmailer.php
File renamed without changes
View
0  php/workers/batch_emailer/lib/class.pop3.php → php/batch_emailer/worker/lib/class.pop3.php
File renamed without changes
View
0  php/workers/batch_emailer/lib/class.smtp.php → php/batch_emailer/worker/lib/class.smtp.php
File renamed without changes
View
0  php/workers/batch_emailer/sendEmail.php → php/batch_emailer/worker/sendEmail.php
File renamed without changes
View
0  php/code/.gitkeep
No changes.
View
21 php/GD_S3.php → php/draw_gd_and_upload_to_s3/enqueue.php
@@ -1,17 +1,13 @@
<?php
-include("../IronWorker.class.php");
+require_once "phar://../iron_worker.phar";
+
/*
* This example demonstrates drawing images using GD library and uploading result to Amazon S3 storage
*/
-$config = parse_ini_file('../config.ini', true);
-
-$name = "testGD_S3.php";
+$worker = new IronWorker();
-$iw = new IronWorker('config.ini');
-
-# Creating and uploading code package.
-$iw->upload(dirname(__FILE__)."/workers/draw_gd_and_upload_to_s3", 'gd_s3.php', $name);
+$config = parse_ini_file('../config.ini', true);
$payload = array(
's3' => array(
@@ -24,12 +20,11 @@
);
# Adding new task.
-$task_id = $iw->postTask($name, $payload);
+$task_id = $worker->postTask("testGD_S3", $payload);
# Wait for task finish
-$details = $iw->waitFor($task_id);
+$details = $worker->waitFor($task_id);
print_r($details);
-$log = $iw->getLog($task_id);
-echo "Task log:\n $log\n";
-
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
7 php/draw_gd_and_upload_to_s3/upload.php
@@ -0,0 +1,7 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+# Creating and uploading code package.
+$worker->upload("worker/", 'gd_s3.php', "testGD_S3");
View
0  ...orkers/draw_gd_and_upload_to_s3/font/Ubuntu-R.ttf → ...draw_gd_and_upload_to_s3/worker/font/Ubuntu-R.ttf
File renamed without changes
View
3  php/workers/draw_gd_and_upload_to_s3/gd_s3.php → php/draw_gd_and_upload_to_s3/worker/gd_s3.php
@@ -2,8 +2,7 @@
require_once dirname(__FILE__) . "/lib/S3.php";
-$args = getArgs();
-$payload = $args['payload'];
+$payload = getPayload();
// Download image.
$raw_image_content = file_get_contents($payload->image_url);
View
0  php/workers/draw_gd_and_upload_to_s3/lib/S3.php → php/draw_gd_and_upload_to_s3/worker/lib/S3.php
File renamed without changes
View
17 php/ffmpeg_flv/enqueue.php
@@ -0,0 +1,17 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$payload = array(
+ 'input_file' => 'https://s3.amazonaws.com/iron-examples/video/iron_man_2_trailer_official.flv'
+);
+$task_id = $worker->postTask("FFmpeg-Flv", $payload);
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
6 php/ffmpeg_flv/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'ffmpeg.php', "FFmpeg-Flv");
View
0  php/workers/ffmpeg_flv/ffmpeg.php → php/ffmpeg_flv/worker/ffmpeg.php
File renamed without changes
View
0  php/workers/ffmpeg_flv/functions.php → php/ffmpeg_flv/worker/functions.php
File renamed without changes
View
14 php/ffmpeg_frames/enqueue.php
@@ -0,0 +1,14 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$task_id = $worker->postTask("FFmpeg-Frames");
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
6 php/ffmpeg_frames/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'ffmpeg.php', "FFmpeg-Frames");
View
0  php/workers/ffmpeg/ffmpeg.php → php/ffmpeg_frames/worker/ffmpeg.php
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame0.gif → php/ffmpeg_frames/worker/frames/Frame0.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame1.gif → php/ffmpeg_frames/worker/frames/Frame1.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame10.gif → php/ffmpeg_frames/worker/frames/Frame10.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame11.gif → php/ffmpeg_frames/worker/frames/Frame11.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame12.gif → php/ffmpeg_frames/worker/frames/Frame12.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame13.gif → php/ffmpeg_frames/worker/frames/Frame13.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame2.gif → php/ffmpeg_frames/worker/frames/Frame2.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame3.gif → php/ffmpeg_frames/worker/frames/Frame3.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame4.gif → php/ffmpeg_frames/worker/frames/Frame4.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame5.gif → php/ffmpeg_frames/worker/frames/Frame5.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame6.gif → php/ffmpeg_frames/worker/frames/Frame6.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame7.gif → php/ffmpeg_frames/worker/frames/Frame7.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame8.gif → php/ffmpeg_frames/worker/frames/Frame8.gif
File renamed without changes
View
0  php/workers/ffmpeg/frames/Frame9.gif → php/ffmpeg_frames/worker/frames/Frame9.gif
File renamed without changes
View
3  php/hello_worker/enqueue.php
@@ -1,6 +1,5 @@
<?php
-
-require "../../IronWorker.class.php";
+require_once "phar://../iron_worker.phar";
$worker = new IronWorker();
View
3  php/hello_worker/upload.php
@@ -1,6 +1,5 @@
<?php
-
-require "../../IronWorker.class.php";
+require_once "phar://../iron_worker.phar";
$worker = new IronWorker();
View
12 php/loggly/enqueue.php
@@ -0,0 +1,12 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+# launch 50 workers
+for ($i = 1; $i <= 50; $i++) {
+ $payload = array('api_key' => LOGGLY_KEY, 'i' => $i);
+
+ $worker->postTask('Loggly', $payload);
+}
View
6 php/loggly/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'loggly.php', "Loggly");
View
0  php/workers/loggly/loggly.php → php/loggly/worker/loggly.php
File renamed without changes
View
18 php/mongo/enqueue.php
@@ -0,0 +1,18 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$config = parse_ini_file('../config.ini', true);
+
+$task_id = $worker->postTask('Mongo', array(
+ 'db' => $config['mongo']
+));
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+# Check log
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
6 php/mongo/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'mongo.php', "Mongo");
View
0  php/workers/mongo/mongo.php → php/mongo/worker/mongo.php
File renamed without changes
View
14 php/mysql/enqueue.php
@@ -0,0 +1,14 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$task_id = $worker->postTask("MySQL");
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
6 php/mysql/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'testMysql.php', "MySQL");
View
0  php/workers/mysql/config.ini → php/mysql/worker/config.ini
File renamed without changes
View
0  php/workers/mysql/testMysql.php → php/mysql/worker/testMysql.php
File renamed without changes
View
12 php/pager_duty/enqueue.php
@@ -0,0 +1,12 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$payload = array(
+ 'API_KEY' => PAGERDUTY_API_KEY
+);
+
+$worker->postTask("PagerDuty", $payload);
+
View
8 php/pager_duty/upload.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->upload("worker/", 'pagerDuty.php', "PagerDuty");
+
View
0  php/workers/pager_duty/pagerDuty.php → php/pager_duty/worker/pagerDuty.php
File renamed without changes
View
21 php/pdo/enqueue.php
@@ -0,0 +1,21 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$config = parse_ini_file('../config.ini', true);
+
+$payload = array(
+ 'connection' => $config['pdo'],
+ 'yet_another_value' => array('value', 'value #2')
+);
+
+$task_id = $worker->postTask("PDO", $payload);
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
6 php/pdo/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'Pdo.php', "PDO");
View
0  php/workers/PDO/Pdo.php → php/pdo/worker/Pdo.php
File renamed without changes
View
8 php/phar_zend/enqueue.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->postTask("pharZend");
+
View
6 php/phar_zend/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'pharZend.php', "pharZend");
View
0  php/workers/phar_zend_lib/pharZend.php → php/phar_zend/worker/pharZend.php
File renamed without changes
View
0  php/workers/phar_zend_lib/zend/zf_1_11_0.phar.gz → php/phar_zend/worker/zend/zf_1_11_0.phar.gz
File renamed without changes
View
8 php/redis/enqueue.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->postTask("Redis");
+
View
8 php/redis/upload.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->upload("worker/", 'testRedis.php', "Redis");
+
View
0  php/workers/php_redis/lib/redis.peer.php → php/redis/worker/lib/redis.peer.php
File renamed without changes
View
0  php/workers/php_redis/lib/redis.php → php/redis/worker/lib/redis.php
File renamed without changes
View
0  php/workers/php_redis/lib/redis.pool.php → php/redis/worker/lib/redis.pool.php
File renamed without changes
View
0  php/workers/php_redis/lib/redis_list.peer.php → php/redis/worker/lib/redis_list.peer.php
File renamed without changes
View
0  php/workers/php_redis/lib/redis_set.peer.php → php/redis/worker/lib/redis_set.peer.php
File renamed without changes
View
0  php/workers/php_redis/testRedis.php → php/redis/worker/testRedis.php
File renamed without changes
View
21 php/scheduling/schedule.php
@@ -0,0 +1,21 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$payload = array(
+ 'key_one' => 'Payload',
+ 'key_two' => 2
+);
+
+# 3 minutes later
+$start_at = time()+3*60;
+
+# Run task every 2 minutes 10 times
+$schedule_id = $worker->postScheduleAdvanced("Scheduling", $payload, $start_at, 2*60, null, 10);
+
+# Get schedule information
+$schedule = $worker->getSchedule($schedule_id);
+print_r($schedule);
+
View
6 php/scheduling/upload.php
@@ -0,0 +1,6 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+
+$worker->upload("worker/", 'worker.php', "Scheduling");
View
3  php/scheduling/worker/worker.php
@@ -0,0 +1,3 @@
+<?php
+
+echo "Hello!";
View
18 php/twitter/enqueue.php
@@ -0,0 +1,18 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$payload = array(
+ 'message' => "Hello From PHPWorker at ".date('r')."!\n",
+ 'url' => 'http://www.iron.io/'
+);
+$task_id = $worker->postTask("Twitter", $payload);
+
+# Wait for task finish
+$details = $worker->waitFor($task_id);
+print_r($details);
+
+$log = $worker->getLog($task_id);
+echo "Task log:\n $log\n";
View
8 php/twitter/upload.php
@@ -0,0 +1,8 @@
+<?php
+require_once "phar://../iron_worker.phar";
+
+$worker = new IronWorker();
+$worker->debug_enabled = true;
+
+$worker->upload("worker/", 'postToTwitter.php', "Twitter");
+
View
0  php/workers/post_to_twitter/config.ini → php/twitter/worker/config.ini
File renamed without changes
View
0  php/workers/post_to_twitter/lib/OAuth.php → php/twitter/worker/lib/OAuth.php
File renamed without changes
View
0  php/workers/post_to_twitter/lib/TwitterOAuth.php → php/twitter/worker/lib/TwitterOAuth.php
File renamed without changes
View
0  php/workers/post_to_twitter/postToTwitter.php → php/twitter/worker/postToTwitter.php
File renamed without changes
View
12 php/workers/hello_world/testTask.php
@@ -1,12 +0,0 @@
-<?php
-
-
-
-echo "Hello PHP World!!!\n";
-echo "at " . date('r') . "\n";
-
-$is_ok = setProgress(50, "Task is half-done");
-$args = getArgs();
-
-print_r($is_ok);
-print_r($args);
View
3  php/workers/hello_world_simple/testTaskSimple.php
@@ -1,3 +0,0 @@
-<?php
-
-echo "Hello PHP World!!!\n";
Please sign in to comment.
Something went wrong with that request. Please try again.