1. Go to this page and download the library: Download clue/docker-react 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/ */
clue / docker-react example snippets
nt = new Clue\React\Docker\Client();
$client->imageSearch('clue')->then(function (array $images) {
var_dump($images);
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$client = new Clue\React\Docker\Client();
// explicitly use given UNIX socket path
$client = new Clue\React\Docker\Client(null, 'unix:///var/run/docker.sock');
// or connect via TCP/IP to a remote Docker Engine API
$client = new Clue\React\Docker\Client(null, 'http://10.0.0.2:8000/');
use function React\Async\await;
$client = new Clue\React\Docker\Client();
$promise = $client->imageInspect('busybox');
try {
$results = await($promise);
// results successfully received
} catch (Exception $e) {
// an error occurred while performing the request
}
use function React\Async\await;
use function React\Promise\all;
$promises = array(
$client->imageInspect('busybox'),
$client->imageInspect('ubuntu'),
);
$inspections = await(all($promises));
$stream = $client->execStartStream($exec, $tty);
$stream->on('data', function ($data) {
// data will be emitted in multiple chunk
echo $data;
});
$stream->on('error', function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$stream->on('close', function () {
// the stream just ended, this could(?) be a good thing
echo 'Ended' . PHP_EOL;
});
$client->imageCreate('clue/streamripper')->then(
function (array $data) {
// $data is an array of *all* elements in the JSON stream
var_dump($data);
},
function (Exception $e) {
// an error occurred (possibly after receiving *some* elements)
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
);
$stream = $client->imageCreateStream('clue/redis-benchmark');
$stream->on('data', function (array $data) {
// data will be emitted for *each* complete element in the JSON stream
echo $data['status'] . PHP_EOL;
});
$stream->on('error', function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$stream->on('close', function () {
// the JSON stream just ended, this could(?) be a good thing
echo 'Ended' . PHP_EOL;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.