定制 greg-boggs/bibliophpile 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

greg-boggs/bibliophpile

Composer 安装命令:

composer require greg-boggs/bibliophpile

包简介

README 文档

README

PHP Wrapper for BiblioCommons API

Credit

Originally written by The New York Public Library: https://www.nypl.org/

Currently maintained by Multnomah County Library: https://multcolib.org/

Installation

Clone the repository, cd onto your cloned directory and run composer:

php composer.phar install 
php composer.phar install --dev

Run tests

alias phpunit='php vendor/phpunit/phpunit/phpunit.php'

phpunit tests

or

phpunit --testdox tests

Generate Documentation

Work fine with PHPDocumentor (and probably others as well).

phpdoc -d src -t docs

To install PHPDocumentor:

pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor-alpha

NOTE: You may have to also install GraphViz in order for phpdoc to run without errors.

Run the Demo

If your are using PHP 5.4 or greater, you can use the built-in web server to run the demo:

php -S localhost:8000

Then go to browser and open `http://localhost:8000/demo.php

Basic Usage

Create a client:

$client = new \NYPL\Bibliophpile\Client('yourapikey');

Via the client you can retrieve the various other BiblioCommons API resources:

$library = $client->library('nypl'); // Returns a Library
$locations = $client->location('nypl'); // Returns a list of Location objects
$list = $client->itemList('1234567'); // Returns an ItemList
$title = $client->title('123456789'); // Returns a Title
$titles = $client->titles('Moby Dick', 'nypl'); // Returns a list of matching Title objects
$user = $client->user('1234567'); // Returns a User
$users = $client->users('example'); // Returns a list of matching User objects
$session = $client->session('a1b2c3d4-e5f6-g7h9-i9j0-k1l2m3n4o5p6'); // Returns a Session
$borrower = $client->borrower('123456'); // Returns a Borrower                       

A note about IDs

Many of the IDs in the examples above are clearly integer-like, but they passed and returned as strings.

Paginated Lists

Some methods return ItemLists Titles or Users objects, which are all paginated lists. Any method that returns a paginated list takes both a page and a limit parameter for the desired page from the results (default: 1) and the number of results per page (default: 10). For example:

// Searches NYPL for “Moby Dick” and returns the 5th page 
// with 20 items per page.
// Returns a Titles object
$client->titles('Moby Dick', 'nypl', 5, 20);

// Gets the 2nd page of lists made by the user, with the 
// default 10 items per page.
// Returns a Users object.
$user->userLists('123456', 2);

The objects themselves share the following methods:

  • count(): Returns the total number of items in the results
  • page(): Returns the current page out the results
  • pages(): Returns the number of pages in the results
  • limit(): Returns the number of items per page
  • gotoPage(page): Retrieves the desired page of results.
  • next(): Retrieves the next page of results.

Trying to get a page that does not exist (less than 1 or higher than the highest numbered page in the results) will raise a NoSuchPageException. Trying to get the next page when you are already at the end of the results raises an EndOfResultsException which can be caught and used a signal to exit a loop when fetching the entire results set.

Empty properties

Many objects returned by the BiblioCommons API can have empty, null, or missing properties. Nypl-bibliophpile handles all these cases by returning an empty array for properties that are expected to be arrays, or NULL for enything else.

Resources

Libraries

Library objects can be retrieved by ID:

$library = $client->library('nypl');
echo $library->id(); // "nypl"
echo $library->name(); // "New York Public Library"
echo $library->catalog(); // "http://nypl.bibliocommons.com"

Locations

A library can have a multiple locations (basically branches). The list of a library’s locations can be retrieved from the Library object:

$locations = $library->locations();
echo $locations[0]->name(); // "115th Street"

or from the client with the library’s ID:

$locations = $client->locations('nypl');

Individual locations also occur as properties in Copy (location of a particular copy) and Borrower objects (as a borrower’s preferred location).

Titles

A “title” can be a book, a DVD, a CD, or anything that can be checked out.

Methods:

additionalContributors() array Additional contributors as an array of names (strings)
authors() array Authors names as an array strings.
availability() Availability
callNumber() string
contents() array Table of contents as an array of strings.
copies() array An array of Copy objects.
description() string
details() string URL for the title on BiblioCommons.
edition() string
format() Format
id() string
isbns() array An array of the title's isbns as strings.
languages() array Array of the title's languages as strings.
name() string Returns the title's name (i.e. it's title, but this method can’t be called title() in order to avoid confusion with a constructor).
notes() array Notes on the title as an array of strings.
pages() int The number of pages
performers() array Title's performers and an array of strings.
physicalDescription() array Physical description of the title as an array of strings.
primaryLanguage() string
publishers() array Array of publishers names as strings.
series() array An array of Series objects.
statementOfResponsibility() string
subtitle() string
suitabilities() array An array of strings.
upcs() array The title's upcs as an array of strings.

Lists

BiblioCommons lists are user-generated lists of Titles

Retrieve a list by it's ID:

$list = $client->itemList('170265611');
echo $list->name(); // "Recommended by our librarians 4";

Titles

Retrieve a title by its ID (NB, the IDs are numeric, but still strings):

$title = $client->title('18708779052907');
echo $title->name(); // "Moby-Dick";

Retrieve the copies of a title:

$copies = $title->copies(); // Array of copy objects

You can also get the copies from the client with the title’s ID:

$copies = $client->copies('18708779052907');

Users

Retrieve a user by ID:

$user = $client->user('123456789');
echo $user->name(); // "fakeuser"

Search for users by username:

$users = $client->users('fakeuser');
$userlist = $users->users(); // array of results
count($users->users()); // 1
echo $userlist[0]->name(); // "fakeuser"

greg-boggs/bibliophpile 适用场景与选型建议

greg-boggs/bibliophpile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 393 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 greg-boggs/bibliophpile 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2022-06-27