Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

primo-services are a PHP interface to Primo's X-Service Web services. It currently supports the brief search and full view services. It can also create Deep Links to Primo searches.


primo-services uses the Composer dependency management system. To install

  1. If you haven't already, install composer.phar. To install composer.phar in the /usr/bin directory on Linux/OS X:

     sudo curl -sS | php -- --install-dir=/usr/bin
  2. Create a composer.json file. The example below will install primo-services:

         "name": "your-organization/your-package",
         "description": "Does something interesting with Primo!",
         "license": "your license here",
         "repositories": [
                 "type": "vcs",
                 "url": ""
         "require": {
                 "bclibraries/primo-services" : "~0.5"
  3. Install using composer.phar:

     php composer.phar install
  4. Instantiate:

      use \BCLib\PrimoServices\PrimoServices;
      use \BCLib\PrimoServices\Query;
      use \BCLib\PrimoServices\QueryTerm;
      $host = ''; //Your Primo host.
      $inst = 'BCL'; // Your Primo institution code.
      $primo = new PrimoServices($host, $inst);


Brief search

First instatiate a connection to the Primo server:

use \BCLib\PrimoServices\PrimoServices;
use \BCLib\PrimoServices\Query;
use \BCLib\PrimoServices\QueryTerm;
use \BCLib\PrimoServices\PrimoException;

$host = '';
$inst = 'BCL';
$primo = new PrimoServices($host, $inst);

Searches are represented by a Query. Each Query can have one or more QueryTerms, which represent search parameters:

$query = new Query('BCL');
$term = new QueryTerm();

Finally execute the search:

try {
    $primo_result = $primo->search($query);
} catch (PrimoException $e) {
    // Handle error

Full view

Full views require a Primo record ID and return a single BibRecord:

$result = $primo->request('ALMA-BC21421259580001021');


The result will be a BriefSearchResult object containing seach result and facet information. The BriefSearchResult object gives access to a list of Facets, a list of BibRecords for the retrieved full results, and a count of the total results of the query.

$facets = $primo_result->facets;
$full_results = $primo_result->results;
$total = $primo_result->total_results;


To see a list of al facets, with facet values

echo "Facets\n";
foreach ($primo_result->facets as $facet) {
    echo "  Id:" . $facet->id . "\n";
    echo "    Count: " . $facet->count . "\n";

    echo "    Values:\n";
    foreach ($facet->values as $value) {
        echo "      " . $value->display_name . " (" . $facet->id . ") - " . $facet->count . "\n";

Full results

Full results are stored in BibRecord objects. A BibRecord contains the following string and string[] components:

foreach ($primo_result->results as $result) {

    // Accessible string and string [] properties of a result
    $result->collection_facet; // string[]
    $result->cover_images; // string[]
    $result->creator_facet; // string[]
    $result->description; // string[]
    $result->genres; // string[]
    $result->isbn; // string []
    $result->issn; // string[]
    $result->languages; // string[]
    $result->openurl; // string[]
    $result->openurl_fulltext; // string[]
    $result->resourcetype_facet; // string[]
    $result->subjects; // string[]
    $result->getit; // string[]

The creator is a Person object:


Each record is composed of BibComponent objects that indicate the source record used to create the Primo record. Most Primo records will have 1 component. De-duplicated records will have multiple components:

foreach ($result->components as $component) {

Each record also has an array of GetIt objects:

foreach ($result->getit as $getit) {

Other PNX fields can be retrieved using field():

foreach ($result->field('display/lds02') as $lds02) {
    echo "$lds02\n";

Deep Links

You can also use the services to generate Deep Links:

$primo_services = new BCLib\PrimoServices\PrimoServices('', 'BCL');
$query_term = new PrimoServices\QueryTerm();

$deep_link = $primo_services->createDeepLink();

$scope = 'bcl';
$tab = 'books_tab';
echo $deep_link->search($query_term, $scope, $tab) . "\n";
echo $deep_link->link('ALMA-BC21421261320001021') . "\n";


Results can be cached by injecting a Doctrine cache object when the service is initialized:

use BCLib\PrimoServices\PrimoServices;
use Doctrine\Common\Cache\ApcCache;

$host = '';
$inst = 'BCL';
$cache = new ApcCache();
$primo = new PrimoServices($host, $inst, $cache);


This module uses the Composer-installed PHPUnit. From the main project directory:

composer test



You can’t perform that action at this time.