Skip to content

Commit bd897fd

Browse files
committed
Use full namespaces in examples
1 parent edf5227 commit bd897fd

15 files changed

+25
-57
lines changed

examples/archive.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@
44
// how it can be passed to a TAR decoder and how we can then pipe each
55
// individual file to the console output.
66

7-
use Clue\CaretNotation\Encoder;
8-
use Clue\React\Docker\Client;
9-
use Clue\React\Tar\Decoder;
10-
use React\Stream\ReadableStreamInterface;
11-
127
require __DIR__ . '/../vendor/autoload.php';
138

149
$container = isset($argv[1]) ? $argv[1] : 'asd';
1510
$path = isset($argv[2]) ? $argv[2] : '/etc/passwd';
1611
echo 'Container "' . $container . '" dumping "' . $path . '" (pass as arguments to this example)' . PHP_EOL;
1712

18-
$client = new Client();
13+
$client = new Clue\React\Docker\Client();
1914

2015
$stream = $client->containerArchiveStream($container, $path);
2116

22-
$tar = new Decoder();
17+
$tar = new Clue\React\Tar\Decoder();
2318

2419
// use caret notation for any control characters except \t, \r and \n
25-
$caret = new Encoder("\t\r\n");
20+
$caret = new Clue\CaretNotation\Encoder("\t\r\n");
2621

27-
$tar->on('entry', function ($header, ReadableStreamInterface $file) use ($caret) {
22+
$tar->on('entry', function ($header, React\Stream\ReadableStreamInterface $file) use ($caret) {
2823
// write each entry to the console output
2924
echo '########## ' . $caret->encode($header['filename']) . ' ##########' . PHP_EOL;
3025
$file->on('data', function ($chunk) use ($caret) {

examples/attach-stream.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
// $ docker run -it --rm --name=foo busybox sh
77
// $ php examples/attach-stream.php foo
88

9-
use Clue\CaretNotation\Encoder;
10-
use Clue\React\Docker\Client;
11-
129
require __DIR__ . '/../vendor/autoload.php';
1310

1411
$container = isset($argv[1]) ? $argv[1] : 'foo';
1512
echo 'Dumping output of container "' . $container . '" (pass as argument to this example)' . PHP_EOL;
1613

17-
$client = new Client();
14+
$client = new Clue\React\Docker\Client();
1815

1916
// use caret notation for any control characters except \t, \r and \n
20-
$caret = new Encoder("\t\r\n");
17+
$caret = new Clue\CaretNotation\Encoder("\t\r\n");
2118

2219
$stream = $client->containerAttachStream($container, true, true);
2320
$stream->on('data', function ($data) use ($caret) {

examples/benchmark-attach.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
// $ docker run -i --rm --log-driver=none busybox dd if=/dev/zero bs=1M count=1000 status=none | dd of=/dev/null
1212

13-
use Clue\React\Docker\Client;
1413
use React\EventLoop\Loop;
1514

1615
require __DIR__ . '/../vendor/autoload.php';
@@ -27,7 +26,7 @@
2726
$cmd = array_slice($argv, 2);
2827
}
2928

30-
$client = new Client();
29+
$client = new Clue\React\Docker\Client();
3130

3231
$client->containerCreate(array(
3332
'Image' => $image,

examples/benchmark-exec.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//
1414
// $ docker exec foo dd if=/dev/zero bs=1M count=1000 | dd of=/dev/null
1515

16-
use Clue\React\Docker\Client;
1716

1817
require __DIR__ . '/../vendor/autoload.php';
1918

@@ -29,7 +28,7 @@
2928
$cmd = array_slice($argv, 2);
3029
}
3130

32-
$client = new Client();
31+
$client = new Clue\React\Docker\Client();
3332

3433
$client->execCreate($container, $cmd)->then(function ($info) use ($client) {
3534
$stream = $client->execStartStream($info['Id'], true);

examples/events.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
// this simple example displays all docker events that happen in the next 10s.
44
// try starting / removing a container in the meantime to see some output.
55

6-
use Clue\React\Docker\Client;
76

87
require __DIR__ . '/../vendor/autoload.php';
98

10-
$client = new Client();
9+
$client = new Clue\React\Docker\Client();
1110

1211
// get a list of all events that happened up until this point
1312
// expect this list to be limited to the last 64 (or so) events

examples/exec-inspect.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
// this simple example executes a "sleep 2" within the given running container
44

5-
use Clue\React\Buzz\Message\ResponseException;
6-
use Clue\React\Docker\Client;
7-
85
require __DIR__ . '/../vendor/autoload.php';
96

107
$container = 'asd';
@@ -18,7 +15,7 @@
1815
$cmd = array_slice($argv, 2);
1916
}
2017

21-
$client = new Client();
18+
$client = new Clue\React\Docker\Client();
2219

2320
$client->execCreate($container, $cmd)->then(function ($info) use ($client) {
2421
echo 'Created with info: ' . json_encode($info) . PHP_EOL;
@@ -38,7 +35,7 @@
3835
}, function (Exception $e) {
3936
echo 'ERROR: ' . $e->getMessage() . PHP_EOL;
4037

41-
if ($e instanceof ResponseException) {
38+
if ($e instanceof React\Http\Message\ResponseException) {
4239
echo 'Response: ' . $e->getResponse()->getBody() . PHP_EOL;
4340
}
4441
});

examples/exec-stream.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
// this example executes some commands within the given running container and
44
// displays the streaming output as it happens.
55

6-
use Clue\React\Docker\Client;
76
use React\EventLoop\Loop;
8-
use React\Stream\WritableResourceStream;
97

108
require __DIR__ . '/../vendor/autoload.php';
119

@@ -24,10 +22,10 @@
2422
$cmd = array_slice($argv, 2);
2523
}
2624

27-
$client = new Client();
25+
$client = new Clue\React\Docker\Client();
2826

29-
$out = new WritableResourceStream(STDOUT);
30-
$stderr = new WritableResourceStream(STDERR);
27+
$out = new React\Stream\WritableResourceStream(STDOUT);
28+
$stderr = new React\Stream\WritableResourceStream(STDERR);
3129

3230
// unkown exit code by default
3331
$exit = 1;

examples/export.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// this example shows how the containerExport() call returns a TAR stream
44
// and how we it can be piped into a output tar file.
55

6-
use Clue\React\Docker\Client;
7-
use React\Stream\WritableResourceStream;
8-
96
require __DIR__ . '/../vendor/autoload.php';
107

118
if (DIRECTORY_SEPARATOR === '\\') {
@@ -16,7 +13,7 @@
1613
$target = isset($argv[2]) ? $argv[2] : ($container . '.tar');
1714
echo 'Exporting whole container "' . $container . '" to "' . $target .'" (pass as arguments to this example)' . PHP_EOL;
1815

19-
$client = new Client();
16+
$client = new Clue\React\Docker\Client();
2017

2118
$stream = $client->containerExportStream($container);
2219

@@ -25,5 +22,5 @@
2522
echo 'ERROR requesting stream' . PHP_EOL . $e;
2623
});
2724

28-
$out = new WritableResourceStream(fopen($target, 'w'));
25+
$out = new React\Stream\WritableResourceStream(fopen($target, 'w'));
2926
$stream->pipe($out);

examples/info.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
// this simple example displays system wide information from Docker as a simple JSON
44

5-
use Clue\React\Docker\Client;
6-
75
require __DIR__ . '/../vendor/autoload.php';
86

9-
$client = new Client();
7+
$client = new Clue\React\Docker\Client();
108

119
$client->info()->then(function ($info) {
1210
echo json_encode($info, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;

examples/logs-stream.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
// this example shows how the containerLogsStream() call can be used to get the logs of the given container.
44
// demonstrates the streaming logs API, which can be used to dump the logs as they arrive
55

6-
use Clue\CaretNotation\Encoder;
7-
use Clue\React\Docker\Client;
8-
96
require __DIR__ . '/../vendor/autoload.php';
107

118
$container = isset($argv[1]) ? $argv[1] : 'asd';
129
echo 'Dumping logs (last 100 lines) of container "' . $container . '" (pass as argument to this example)' . PHP_EOL;
1310

14-
$client = new Client();
11+
$client = new Clue\React\Docker\Client();
1512

1613
// use caret notation for any control characters except \t, \r and \n
17-
$caret = new Encoder("\t\r\n");
14+
$caret = new Clue\CaretNotation\Encoder("\t\r\n");
1815

1916
$stream = $client->containerLogsStream($container, true, true, true, 0, false, 100);
2017
$stream->on('data', function ($data) use ($caret) {

0 commit comments

Comments
 (0)