PHP code example of clue / viewvc-api-react

1. Go to this page and download the library: Download clue/viewvc-api-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 / viewvc-api-react example snippets


$loop = React\EventLoop\Factory::create();
$browser = new Clue\React\Buzz\Browser($loop);
$client = new Client($browser->withBase('http://example.com/viewvc/'));

$client->fetchDirectory('/')->then(function ($files) {
    echo 'Files: ' . implode(', ', $files) . PHP_EOL;
});

$loop->run();

$loop = React\EventLoop\Factory::create();
$browser = new Clue\React\Buzz\Browser($loop);

$client = new Client($browser->withBase('http://example.com/viewvc/'));

$client->fetchDirectory($path, $revision = null);
$client->fetchFile($path, $revision = null);
$client->fetchPatch($path, $r1, $r2);
$client->fetchLog($path, $revision = null);

// many more…

$client->fetchFile($path)->then(
    function ($contents) {
        // file contents received
    },
    function (Exception $e) {
        // an error occured while executing the request
    }
});

use Clue\React\Block;

$loop = React\EventLoop\Factory::create();
$browser = new Clue\React\Buzz\Browser($loop);

$client = new Client($browser->withBase($uri /* change me */));
$promise = $client->fetchFile($path /* change me */);

try {
    $contents = Block\await($promise, $loop);
    // file contents received
} catch (Exception $e) {
    // an error occured while executing the request
}

$client->fetchFile($path);

$stream = $client->fetchFileStream($path);

$stream->on('data', function ($chunk) {
    echo $chunk;
});

$stream->on('error', function (Exception $error) {
    echo 'Error: ' . $error->getMessage() . PHP_EOL;
});

$stream->on('close', function () {
    echo '[DONE]' . PHP_EOL;
});