cleverage / php-trac
Api for querying Trac RPC
1.0.1
2015-01-26 16:27 UTC
Requires
- php: >=5.3
- symfony/options-resolver: >=2.3
Suggests
- guzzle/guzzle: v3.7.4
- kriswallsmith/buzz: dev-master
This package is auto-updated.
Last update: 2024-10-29 04:30:51 UTC
README
#CleverAge\Trac
Interface PHP 5.3+ to query TRAC via its RPC
api. JSON
version is actually
used.
Installation
With composer : php composer.phar require "cleverage/php-trac": "dev-master"
It needs Buzz (default with Curl) or Guzzle to proceed HTTP queries.
Compatibility
Tested with Trac 0.12 and API version 1.1.2-r12546.
##Exemples
$tracOptions = array(
'url' => 'http://www.mytrac.org',
);
$client = new \CleverAge\Trac\HttpClient\Guzzle\GuzzleHttpClient();
// $client = new \CleverAge\Trac\HttpClient\Buzz\BuzzHttpClient();
$trac = new \CleverAge\Trac\TracApi($tracOptions, $client);
$ticket = $trac->getTicketById(101);
echo $ticket->id. ' : '.$ticket->status;
$tickets = $trac->getTicketByStatus($status='closed', $limit=100);
foreach ($tickets as $ticket) {
echo $ticket->id. ' : '.$ticket->status;
}
Options
url
(required): The trac main urlticket.class
: The class object to use when getting tickets. Default isCleverAge\Trac\Ticket
.auth
: Supports none and Basic http. UseCleverAge\Trac\TracApi::AUTH_*
constants, default isAUTH_NONE
.- if
auth
isAUTH_BASIC
, then you must provideuser.login
anduser.password
.
- if
Performances
If you use Guzzle HttpClient, some requests are parallelized, so it improves performances, using MultiCurl :
$tracOptions = array(
'url' => 'http://www.mytrac.org',
);
$client = new \CleverAge\Trac\HttpClient\Guzzle\GuzzleHttpClient();
$client->setParallelLimit(10); // default is 5
$trac = new \CleverAge\Trac\TracApi($tracOptions, $client);
$tickets = $trac->getManyTicketsByIds(array(100, 101, 102, 103));
foreach ($tickets as $ticket) {
echo $ticket->id. ' : '.$ticket->status;
}