createClient(); $stream = $client->imageCreateStream($image); $stream->on('progress', function ($progress) { echo 'progress: '. json_encode($progress) . PHP_EOL; }); $stream->on('close', function () { echo 'stream closed' . PHP_EOL; }); $loop->run();