承接 scriptotek/sru-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scriptotek/sru-client

Composer 安装命令:

composer require scriptotek/sru-client

包简介

Package for making Search/Retrieve via URL requests and parse the responses

关键字:

README 文档

README

Coverage Code Quality Latest Stable Version Total Downloads

php-sru-client

Simple PHP package for making Search/Retrieve via URL (SRU) requests and returning QuiteSimpleXMLElement objects. The response object is an iterator, to support easy iteration over the results, abstracting away the process of making multiple requests.

If you prefer a simple text response, you might have a look at the php-sru-search package.

Install using Composer

Use Composer to install sru-client with a HTTP library such as Guzzle:

composer require scriptotek/sru-client php-http/guzzle6-adapter http-interop/http-factory-guzzle

We use HTTP discovery to discover HTTP client and HTTP factory implementations, so Guzzle can be swapped with any other PSR-17/PSR-18-compatible library.

Configuring the client

require_once('vendor/autoload.php');
use Scriptotek\Sru\Client as SruClient;

$sru = new SruClient('http://bibsys-network.alma.exlibrisgroup.com/view/sru/47BIBSYS_NETWORK', [
    'schema' => 'marcxml',
    'version' => '1.2',
    'user-agent' => 'MyTool/0.1',
]);

Search and retrieve

To get all the records matching a given CQL query:

$records = $sru->all('alma.title="Hello world"');
foreach ($records as $record) {
	echo "Got record " . $record->position . " of " . $records->numberOfRecords() . "\n";
	// processRecord($record->data);
}

where $record is an instance of Record and $record->data is an instance of QuiteSimpleXMLElement.

The all() method takes care of continuation for you under the hood for you; the Records generator continues to fetch records until the result set is depleted. A default batch size of 10 is used, but you can give any number supported by the server as a second argument to the all() method.

If you query for some identifier, you can use the convenience method first():

$record = $sru->first('alma.isbn="0415919118"');

The result is a Record object, or null if not found.

Use explain to get information about servers

$urls = array(
    'http://sru.bibsys.no/search/biblio',
    'http://lx2.loc.gov:210/LCDB',
    'http://services.d-nb.de/sru/zdb',
    'http://api.libris.kb.se/sru/libris',
);

foreach ($urls as $url) {

    $sru = new SruClient($url, [
        'version' => '1.1',
        'user-agent' => 'MyTool/0.1'
    ]);

    try {
        $response = $sru->explain();
    } catch (\Scriptotek\Sru\Exceptions\SruErrorException $e) {
        print 'ERROR: ' . $e->getMessage() . "\n";
        continue;
    }

    printf("Host: %s:%d\n", $response->host, $response->port);
    printf("  Database: %s\n", $response->database->identifier);
    printf("  %s\n", $response->database->title);
    printf("  %s\n", $response->database->description);
    print "  Indexes:\n";
    foreach ($response->indexes as $idx) {
        printf("   - %s: %s\n", $idx->title, implode(' / ', $idx->maps));
    }

}

Laravel 5 integration

Add the service provider to the 'providers' array in config/app.php:

Scriptotek\Sru\Providers\SruServiceProvider::class,

Optionally, add the facade to the 'aliases' array in the same file:

'SruClient'      => Scriptotek\Sru\Facades\SruClient::class,

To create the configuration file config/sru.php:

$ php artisan vendor:publish --provider="Scriptotek\Sru\Providers\SruServiceProvider"

scriptotek/sru-client 适用场景与选型建议

scriptotek/sru-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.8k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2014 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「sru」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 scriptotek/sru-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 scriptotek/sru-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 scriptotek/sru-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

与 scriptotek/sru-client 相关的其它包

同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:

统计信息

  • 总下载量: 6.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 18
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-26