Skip to content

clue/php-viewvc-api-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clue/viewvc-api-react Build Status

Simple, async API-like access to your ViewVC web interface (Subversion/CVS browser), built on top of React PHP.

Note: This project is in beta stage! Feel free to report any issues you encounter.

Quickstart example

Once installed, you can use the following code to fetch a directory listing from the given ViewVC URL:

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

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

$loop->run();

See also the examples.

Usage

Client

The Client is responsible for assembling and sending HTTP requests to the remote ViewVC web interface. It requires a Browser object bound to the main EventLoop in order to handle async requests:

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

$client = new Client($url, $browser);

If you need custom DNS or proxy settings, you can explicitly pass a custom Browser instance.

Actions

ViewVC does not officially expose an API. However, its REST-like URLs make it easy to construct the right requests and scrape the results from its HTML output. All public methods resemble these respective actions otherwise available in the ViewVC web interface.

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

// many more…

Listing all available actions is out of scope here, please refer to the class outline.

Processing

Sending requests is async (non-blocking), so you can actually send multiple requests in parallel. ViewVC will respond to each request with a response message, the order is not guaranteed. Sending requests uses a Promise-based interface that makes it easy to react to when a request is fulfilled (i.e. either successfully resolved or rejected with an error).

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

Install

The recommended way to install this library is through composer. New to composer?

{
    "require": {
        "clue/viewvc-api-react": "~0.1.0"
    }
}

License

MIT

About

Simple, async access to your ViewVC web interface, built on top of React PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages