A client for accessing the Primo Brief Search RESTful API in PHP.
Use composer to install Primo-Client.
composer require bclibraries/primo-client:^0.3Primo Client is currently a 0.* release, so things might change drastically with any minor release.
Create a configuration hash and pass it to PrimoClient::build() to
instantiate a client.
require_once __DIR__.'/vendor/autoload.php';
$config = [
'apikey' => 'l7xx38c6a1a3043974262e81a81fb7475ba9',
'gateway' => 'https://api-na.hosted.exlibrisgroup.com',
'vid' => 'my_vid',
'tab' => 'the_tab',
'scope' => 'mylib'
];
$primo = \BCLib\PrimoClient\PrimoClient::build(
$config['gateway'],
$config['apikey'],
$config['tab'],
$config['vid'],
$config['scope']
);
$response = $primo->search('otters');Passing a string to search() will perform a simple keyword search. For more complex searches, pass in a
SearchRequest object:
$request = $primo->getSearchRequest();
$contains_manchurian_candidate = new \BCLib\PrimoClient\Query('any','contains','manchurian candidate');
$contains_demme = new \BCLib\PrimoClient\Query('creator','contains','demme');
$is_video = new \BCLib\PrimoClient\QueryFacet('facet_rtype','exact','video');
$request->addQuery($contains_manchurian_candidate)
->addQuery($contains_demme, 'NOT')
->include($is_video)
->sort('date')
->limit(5);
$response = $primo->search($request);The JSON structure of a SearchResponse can be accessed directly:
echo "{$response->json->info->total} total results\n";
foreach ($response->json->docs as $doc) {
echo "{$doc->pnx->display->title[0]}\n";
}or through convenience parameters:
echo "{$response->total} total results\n";
foreach ($response->docs as $doc) {
echo "{$doc->title}\n";
}PHPUnit is used for testing. To run:
vendor/bin/phpunit test- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request
Please make sure to update tests as appropriate.