HOWTO get the Yaz libraries up and running in your PHP5 installation

Reposted from old site – original date: Friday 6 August 2010
YAZ is a programmers toolkit supporting the development of Z39.50/SRW/SRU clients and servers. Z39.50-2003 (version 3) as well as SRW/SRU version 1.1 are supported in both the client and server roles.

The current version of YAZ includes support for the industry standard ZOOM API for Z39.50. This API vastly simplifies the process of writing new clients using YAZ, and it reduces your dependency on any single toolkit.

The PECL extension is described as:

PHP/YAZ is an extension to the popular web server language PHP that implements Z39.50 origin (client) functionality as well as the SRW/SRU protocols.

The following Z39.50 services are supported by this extension: init, search, present, scan and sort. The extension can handle GRS-1, MARC, SUTRS and XML. The module also allows you to convert MARC in ISO2709 to MARCXML on the client side.

The PHP/YAZ extension is part of PHP 4.0.1 and later but has now been moved to PECL. As a PECL module, PHP/YAZ is now independent of PHP versions. It works with both PHP 4 and PHP 5.

You need to install the YAZ dev libraries as well to get the headers so that the PECL extension can build against them. So now we install the lot with:

aptitude install libyaz3 libyaz3-dev yaz-doc
pecl install yaz

Once the YAZ extension is built properly, you must then remember to add your new extension to the php.ini file so that PHP knows about it. I am using Apache, so I add it to the apache2/php.ini file.

Restart/Reload Apache and then check for the new extension with

php -i | grep yaz

on the commandline, or use a regular phpinfo() call within a PHP script. Remember that if you use the commandline only, you will also need to add the yaz extension line to your cli.ini file!

With that, you should be up and running with YAZ in PHP5

Liked this post? Follow this blog to get more.