/php-sip2

PHP class library to facilitate communication with Integrated Library System (ILS) servers via 3M's SIP2.

Primary LanguagePHPMIT LicenseMIT

php-sip2

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP client library to facilitate communication with Integrated Library System (ILS) servers via 3M's SIP2.

This is derived from cap60552/php-sip2 by John Wohlers, with following improvements:

  • MIT license (with consent of original author who used GPL)
  • Separate classes for each SIP2 request and response type
  • Ability to bind to specific interface when making requests
  • Full unit tests
  • PSR-2 formatting conventions
  • PSR-3 logging
  • PSR-4 auto-loading

Install

Via Composer

$ composer require lordelph/php-sip2

Example

Here's a typical example of use

use lordelph\SIP2\SIP2Client;
use lordelph\SIP2\Request\PatronInformationRequest;

// instantiate client, set any defaults used for all requests,
// typically you might set the PatronIdentifier and PatronPassword
// so that you don't have to set this for every request
$mysip = new SIP2Client;
$mysip->setDefault('PatronIdentifier', '101010101');
$mysip->setDefault('PatronPassword', '010101');

// connect to SIP server 
$mysip->connect("server.example.com:6002");

// to make a request, instantiate relevant request class
// and configure as appropriate
$request=new PatronInformationRequest();
$request->setType('charged');

// send the request, obtaining, in this case a
// PatronInformationResponse object
$response = $mysip->sendRequest($request);

// now we can obtain information from the result object
$status = $response->getPatronStatus();
$name = $response->getPersonalName();

SIP2 requests and responses

All requests defined in SIP2 are available - note that not all SIP2 services will support every request.

Request Response
PatronStatusRequest PatronStatusResponse
CheckOutRequest CheckOutResponse
CheckInRequest CheckInResponse
BlockPatronRequest PatronStatusResponse
SCStatusRequest ASCStatusResponse
RequestACSResendRequest previous response
LoginRequest LoginResponse
PatronInformationRequest PatronInformationResponse
EndPatronSessionRequest EndSessionResponse
FeePaidRequest FeePaidResponse
ItemInformationRequest ItemInformationResponse
ItemStatusUpdateRequest ItemStatusUpdateResponse
PatronEnableRequest PatronEnableResponse
HoldRequest HoldResponse
RenewRequest RenewResponse
RenewAllRequest RenewAllResponse

Migration from v1.0

See MIGRATION for details.

Binding to a specific local outbound address

If connecting to a SIP2 service over the internet, such services will usually be tightly firewalled to specific IPs. If your client software is running on a machine with multiple outbound interfaces, you may wish to pick the specific interface so that the SIP2 server sees the correct IP.

To do this, specify the IP with bindTo public member variable before calling connect():

use lordelph\SIP2\SIP2Client;


// create object
$mysip = new SIP2Client;

// Set host name
$mysip->hostname = 'server.example.com';
$mysip->port = 6002;

//ensure outbound connections go from this IP address
$mysip->bindTo = '1.2.3.4';

// connect to SIP server 
$result = $mysip->connect();

Disabling CRC checks

Some SIP2 server implementations can provide CRCs which are invalid. You can configure the client to skip CRC checks with SIP2Client::enableCRCCheck(false);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email paul@elphin.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that prior to v2.0.0, the GPL licence was used. The original author, John Wohlers, kindly agreed to allow the MIT license terms.