roblib/rapidillrequest

PHP library for creating InterLibrary Loan requests via the RapidILL API

Maintainers

Package info

git.library.upei.ca/Code/rapidILLRequest.git

pkg:composer/roblib/rapidillrequest

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

dev-main 2026-03-25 17:35 UTC

This package is not auto-updated.

Last update: 2026-03-26 15:49:22 UTC


README

A PHP library for creating InterLibrary Loan (ILL) requests using the RapidILL API InsertRequest method.

Built on PHP's native SoapClient with no framework dependencies, making it easy to use in any PHP project including Drupal 10.

Requirements

  • PHP 8.1 or higher
  • PHP SOAP extension (ext-soap)

Installation

Composer

composer require roblib/rapidillrequest

Drupal 10

composer require roblib/rapidillrequest

Quick Start

use RapidIll\RapidIllClient;
use RapidIll\InsertRequest;
use RapidIll\RequestType;

// Create a client with your RapidILL credentials.
$client = new RapidIllClient(
    username: 'your_username',
    password: 'your_password',
    rapidCode: 'YOUR_RAPID_CODE',
    branchName: 'Main',
);

// Build and submit a request.
$request = (new InsertRequest())
    ->setRequestType(RequestType::Article)
    ->setJournalTitle('Nature')
    ->setArticleTitle('A breakthrough in quantum computing')
    ->setArticleAuthor('Smith, J.')
    ->addIssn('0028-0836');

$response = $client->insertRequest($request);

if ($response->isSuccessful) {
    echo "Request submitted. Rapid ID: {$response->rapidRequestId}\n";
}

Examples

Request a journal article

use RapidIll\RapidIllClient;
use RapidIll\InsertRequest;
use RapidIll\RequestType;

$client = new RapidIllClient(
    username: 'your_username',
    password: 'your_password',
    rapidCode: 'YOUR_RAPID_CODE',
    branchName: 'Main',
);

$request = (new InsertRequest())
    ->setRequestType(RequestType::Article)
    ->setJournalTitle('Nature')
    ->setJournalYear('2024')
    ->setJournalVolume('625')
    ->setJournalIssue('7994')
    ->setJournalMonth('January')
    ->setArticleTitle('A breakthrough in quantum computing')
    ->setArticleAuthor('Smith, J.')
    ->setArticlePages('100-105')
    ->addIssn('0028-0836')
    ->addIssn('1476-4687')
    ->setOclcNumber('1234567')
    ->setPatronName('Jane Doe')
    ->setPatronEmail('jane.doe@university.edu')
    ->setPatronDepartment('Physics')
    ->setXrefRequestId('ILL-2024-00042');

$response = $client->insertRequest($request);

if ($response->isSuccessful) {
    echo "Request ID: {$response->rapidRequestId}\n";
    echo "Match found: " . ($response->foundMatch ? 'yes' : 'no') . "\n";
    echo "Available holdings: {$response->numberOfAvailableHoldings}\n";
} else {
    echo "Request failed: {$response->verificationNote}\n";
}

Request a book

$request = (new InsertRequest())
    ->setRequestType(RequestType::Book)
    ->setJournalTitle('Introduction to Algorithms')
    ->setArticleAuthor('Cormen, Thomas H.')
    ->addIsbn('978-0262033848')
    ->setPublisher('MIT Press')
    ->setEdition('3rd')
    ->setPatronName('John Smith')
    ->setPatronEmail('john.smith@university.edu');

$response = $client->insertRequest($request);

Request a book chapter

$request = (new InsertRequest())
    ->setRequestType(RequestType::BookChapter)
    ->setJournalTitle('The Oxford Handbook of Innovation')
    ->setArticleTitle('Open Innovation')
    ->setArticleAuthor('Chesbrough, Henry')
    ->setArticlePages('191-213')
    ->addIsbn('978-0199286805')
    ->setPatronName('Alice Johnson')
    ->setPatronEmail('alice@university.edu');

$response = $client->insertRequest($request);

Check holdings only (without submitting a request)

$request = (new InsertRequest())
    ->setRequestType(RequestType::Article)
    ->setHoldingsCheckOnly(true)
    ->setJournalTitle('Science')
    ->addIssn('0036-8075');

$response = $client->insertRequest($request);

if ($response->isLocalHolding) {
    echo "Item is available locally:\n";
    foreach ($response->localHoldings as $holding) {
        echo "  Branch: {$holding['branchName']}\n";
        echo "  Location: {$holding['location']}\n";
        echo "  Call Number: {$holding['callNumber']}\n";
    }
} else {
    echo "Not held locally. {$response->numberOfAvailableHoldings} remote holdings available.\n";
}

Error handling

use RapidIll\RapidIllException;

try {
    $response = $client->insertRequest($request);
} catch (RapidIllException $e) {
    // SOAP or connection error.
    error_log('RapidILL error: ' . $e->getMessage());
}

Debugging SOAP requests

The client records the raw SOAP XML when trace is enabled (the default):

$response = $client->insertRequest($request);

// Inspect the XML that was sent and received.
echo $client->getLastRequest();
echo $client->getLastResponse();

API Reference

RapidIllClient

Constructor ParameterTypeRequiredDescription
usernamestringyesRapidILL API username
passwordstringyesRapidILL API password
rapidCodestringyesYour library's Rapid code
branchNamestringyesYour library branch name
wsdlUrlstringnoOverride the default WSDL URL
soapOptionsarraynoAdditional options passed to SoapClient

InsertRequest

All setters return $this for fluent chaining.

MethodDescription
setRequestType(RequestType)Article, Book, or BookChapter (default: Article)
setHoldingsCheckOnly(bool)If true, only checks holdings without submitting
setBlockLocalOnly(bool)Block request if only local holdings exist
setInsertLocalHolding(bool)Insert a local holding record
addIssn(string)Add an ISSN
setIssns(array)Set all ISSNs at once
addIsbn(string)Add an ISBN
setIsbns(array)Set all ISBNs at once
addLccn(string)Add an LCCN
setLccns(array)Set all LCCNs at once
setOclcNumber(string)OCLC number
setJournalTitle(string)Journal or book title
setJournalYear(string)Publication year
setJournalVolume(string)Volume number
setJournalIssue(string)Issue number
setJournalMonth(string)Publication month
setArticleTitle(string)Article or chapter title
setArticleAuthor(string)Author name
setArticlePages(string)Page range
setEdition(string)Edition
setPublisher(string)Publisher
setPatronId(string)Patron identifier
setPatronName(string)Patron full name
setPatronDepartment(string)Patron department
setPatronEmail(string)Patron email address
setPatronPhone(string)Patron phone number
setPatronNotes(string)Additional notes
setXrefRequestId(string)Cross-reference ID from your ILL system

InsertResponse

All properties are readonly.

PropertyTypeDescription
isSuccessfulboolWhether the API call succeeded
foundMatchboolWhether a lending match was found
rapidRequestIdintThe assigned Rapid request ID
numberOfAvailableHoldingsintCount of available holdings
isLocalHoldingboolWhether the item is held locally
verificationNote?stringError or informational message
matchingStandardNumber?stringThe matched ISSN/ISBN
matchingStandardNumberType?stringType of the matched number
duplicateRequestId?stringID if request is a duplicate
localHoldingsarrayArray of local holding records

RequestType (enum)

  • RequestType::Article
  • RequestType::Book
  • RequestType::BookChapter

Testing

composer install
vendor/bin/phpunit

License

GPL-2.0-or-later