The purpose of this class is to interact with the Trac API from a remote location by remote procedure calls.
Trac is a project management and bug/issue tracking system. http://trac.edgewall.org/
Trac by itself does not provide an API. You must install the XmlRpcPlugin. Trac then provides anonymous and authenticated access to the API via two protocols XML-RPC and JSON-RPC. http://trac-hacks.org/wiki/XmlRpcPlugin/
a) Download the ZIP from Github, then extract the library file and include it.
b) Installation via Composer
To add PHPTracRPC as a local, per-project dependency to your project, simply add jakoch/php-trac-rpc
to your project's composer.json
file.
{
"require": {
"jakoch/php-trac-rpc": "dev-master"
}
}
When you installed via Composer, please include the Composer Autoloader first and then instantiate the TracRPC class.
include __DIR__.'/vendor/autoload.php';
When you fetched the zip file, please include the lib directly.
include __DIR__.'/lib/TracRPC.php';
$credentials = array('username' => 'username', 'password' => 'password');
$trac = new \TracRPC\TracRPC('http://trac.example.com/login/jsonrpc', $credentials);
$result = $trac->getTicket('32');
if ($result === false) {
die('ERROR: '.$trac->getErrorMessage());
} else {
var_dump($result);
}
$trac->setMultiCall(true);
$ticket = $trac->getTicket('32');
$attachments = $trac->getTicketAttachments('list', '32');
$trac->doRequest();
$ticket = $trac->getResponse($ticket);
$attachments = $trac->getResonse($attachments);
var_dump($ticket, $attachments);