Skip to content

Commit a08c24e

Browse files
committed
Update README.md
1 parent 36d554b commit a08c24e

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

README.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
## php-sru-client
55

6-
A simple PHP class for making [Search/Retrieve via URL](http://www.loc.gov/standards/sru/) (SRU) requests,using the
6+
Simple PHP package for making [Search/Retrieve via URL](http://www.loc.gov/standards/sru/) (SRU) requests, using the
77
[Guzzle HTTP client](http://guzzlephp.org/)
88
and returning
9-
[QuiteSimpleXMLElement](//github.com/danmichaelo/quitesimplexmlelement) instances.
9+
[QuiteSimpleXMLElement](//github.com/danmichaelo/quitesimplexmlelement) instances. Includes an iterator to easily iterate over search results, abstracting away the process of making multiple requests.
1010

1111
If you prefer a simple text response, you might have a look at
1212
the [php-sru-search](https://github.com/Zeitschriftendatenbank/php-sru-search) package.
@@ -36,11 +36,11 @@ $url = 'http://sru.bibsys.no/search/biblioholdings';
3636
$client = new SruClient($url, array(
3737
'schema' => 'marcxml',
3838
'version' => '1.1',
39-
'user-agent' => 'OpenKat/0.1'
39+
'user-agent' => 'MyTool/0.1'
4040
));
4141
```
4242

43-
To iterate over all the results from a `searchRetrieve` query, use the [Records](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Records.html) class returned from `Client::records()`. It abstracts away the process of actually making the requests. The first argument is
43+
To iterate over all the results from a `searchRetrieve` query, use the [Records](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Records.html) class returned from `Client::records()`. The first argument is
4444
the CQL query, and the second optional argument is the number of records to fetch for each request (defaults to 10).
4545

4646
```php
@@ -54,6 +54,42 @@ foreach ($records as $record) {
5454
}
5555
```
5656

57+
Use explain to get information about servers:
58+
59+
```php
60+
$urls = array(
61+
'http://sru.bibsys.no/search/biblio',
62+
'http://lx2.loc.gov:210/LCDB',
63+
'http://services.d-nb.de/sru/zdb',
64+
'http://api.libris.kb.se/sru/libris',
65+
);
66+
67+
foreach ($urls as $url) {
68+
69+
$client = new SruClient($url, array(
70+
'version' => '1.1',
71+
'user-agent' => 'MyTool/0.1'
72+
));
73+
74+
$response = $client->explain();
75+
76+
if ($response->error) {
77+
print 'ERROR: ' . $response->error . "\n";
78+
continue;
79+
}
80+
81+
printf("Host: %s:%d\n", $response->host, $response->port);
82+
printf(" Database: %s\n", $response->database->identifier);
83+
printf(" %s\n", $response->database->title);
84+
printf(" %s\n", $response->database->description);
85+
print " Indexes:\n";
86+
foreach ($response->indexes as $idx) {
87+
printf(" - %s: %s\n", $idx->title, implode(' / ', $idx->maps));
88+
}
89+
90+
}
91+
```
92+
5793
### API documentation
5894

5995
API documentation can be generated using e.g. [Sami](https://github.com/fabpot/sami),

0 commit comments

Comments
 (0)