You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple PHP package for making [Search/Retrieve via URL](http://www.loc.gov/standards/sru/) (SRU) requests, using the
11
-
[Guzzle HTTP client](http://guzzlephp.org/)
12
-
and returning
10
+
Simple PHP package for making [Search/Retrieve via URL](http://www.loc.gov/standards/sru/) (SRU) requests, using the [Guzzle HTTP client](http://guzzlephp.org/) and returning
13
11
[QuiteSimpleXMLElement](//github.com/danmichaelo/quitesimplexmlelement) instances. Includes an iterator to easily iterate over search results, abstracting away the process of making multiple requests.
14
12
15
13
If you prefer a simple text response, you might have a look at
16
14
the [php-sru-search](https://github.com/Zeitschriftendatenbank/php-sru-search) package.
17
15
18
-
###Install using Composer
16
+
## Install using Composer
19
17
20
-
Add the package to the `require` list of your `composer.json` file.
18
+
Make sure you have [Composer](https://getcomposer.org) installed, then run
21
19
22
-
```json
23
-
{
24
-
"require": {
25
-
"scriptotek/sru-client": "dev-master"
26
-
},
27
-
}
20
+
```bash
21
+
composer require scriptotek/alma-client
28
22
```
29
23
30
-
and run `composer install` to get the latest version of the package.
31
-
32
-
### Laravel 5 integration
33
-
34
-
In the $providers array add the service providers for this package:
24
+
in your project directory to get the latest stable version of the package.
$sru = new SruClient('http://bibsys-network.alma.exlibrisgroup.com/view/sru/47BIBSYS_NETWORK', [
57
33
'schema' => 'marcxml',
58
-
'version' => '1.1',
59
-
'user-agent' => 'MyTool/0.1'
60
-
));
34
+
'version' => '1.2',
35
+
'user-agent' => 'MyTool/0.1',
36
+
]);
61
37
```
62
38
63
-
To get the first record matching a query:
64
-
```php
65
-
$client->first('bs.isbn="0415919118"');
66
-
```
67
-
The result is a [Record](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Record.html)
68
-
object, or `null` if not found.
39
+
## Search and retrieve
69
40
70
-
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) object returned from `Client::records()`. The first argument is
71
-
the CQL query, and the second optional argument is the number of records to fetch for each request (defaults to 10).
41
+
To get all the records matching a given CQL query:
echo "Got record " . $record->position . " of " . $records->numberOfRecords() . "\n";
80
47
// processRecord($record->data);
81
48
}
82
49
```
83
50
84
-
#### Use explain to get information about servers:
51
+
where `$record` is an instance of [Record](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Record.html) and `$record->data` is an instance of [QuiteSimpleXMLElement](https://github.com/danmichaelo/quitesimplexmlelement).
52
+
53
+
The `all()` method takes care of continuation for you under the hood for you;
54
+
the [Records](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Records.html) generator
55
+
continues to fetch records until the result set is depleted. A default batch size of 10 is used,
56
+
but you can give any number supported by the server as a second argument to the `all()` method.
57
+
58
+
If you query for some identifier, you can use the convenience method `first()`:
59
+
60
+
```php
61
+
$record = $sru->first('alma.isbn="0415919118"');
62
+
```
63
+
64
+
The result is a [Record](//scriptotek.github.io/php-sru-client/api_docs/Scriptotek/Sru/Record.html)
0 commit comments