Skip to content

Commit 10beb65

Browse files
committed
Add push example
1 parent d077ff8 commit 10beb65

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

examples/push.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
// this example shows how the imagePush() call can be used to publish a given image.
3+
// this requires authorization and this example includes some invalid defaults.
4+
5+
require __DIR__ . '/../vendor/autoload.php';
6+
7+
use React\EventLoop\Factory as LoopFactory;
8+
use Clue\React\Docker\Factory;
9+
10+
$image = isset($argv[1]) ? $argv[1] : 'asd';
11+
$auth = json_decode('{"username": "string", "password": "string", "email": "string", "serveraddress" : "string", "auth": ""}');
12+
echo 'Pushing image "' . $image . '" (pass as argument to this example)' . PHP_EOL;
13+
14+
$loop = LoopFactory::create();
15+
16+
$factory = new Factory($loop);
17+
$client = $factory->createClient();
18+
19+
$client->imagePush($image, null, null, $auth)->then(
20+
function ($response) {
21+
echo 'response: ' . json_encode($response) . PHP_EOL;
22+
},
23+
'var_dump',
24+
function ($info) {
25+
echo 'update: ' . json_encode($info) . PHP_EOL;
26+
}
27+
);
28+
29+
$loop->run();

0 commit comments

Comments
 (0)