ck/php-marcspec
Composer 安装命令:
composer require ck/php-marcspec
包简介
PHP based MARCspec parser and validator
README 文档
README
PHP MARCspec parser and validator.
For currently supported version of MARCspec - A common MARC record path language see http://marcspec.github.io/ .
Installation
Installation can be done by using composer. Just run
composer require ck/php-marcspec
PHP-MARCspec requires PHP 7.4 or later.
Usage
<?php require("vendor/autoload.php"); use CK\MARCspec\MARCspec; use CK\MARCspec\Field; use CK\MARCspec\Subfield; use CK\MARCspec\ComparisonString; use CK\MARCspec\SubSpec; // parse and access MARCspec like an array $fixed = new MARCspec('007[0]/1-8{/0=\a}'); $fixed['field']; // CK\MARCspec\FieldInterface echo $fixed['field']['tag']; // '007' echo $fixed['field']['charStart']; // 1 echo $fixed['field']['charEnd']; // 8 echo $fixed['field']['charLength']; // 8 $fixed['field']['subSpecs'][0]['leftSubTerm']; // CK\MARCspec\MARCspecInterface echo $fixed['field']['subSpecs'][0]['leftSubTerm']; // '007[0]/0' echo $fixed['field']['subSpecs'][0]['operator']; // '=' $fixed['field']['subSpecs'][0]['rightSubTerm']; // CK\MARCspec\ComparisonStringInterface echo $fixed['field']['subSpecs'][0]['rightSubTerm']; // '\a' echo $fixed['field']['subSpecs'][0]['rightSubTerm']['comparable']; // 'a' $fixed; // CK\MARCspec\MARCspecInterface echo $fixed; // '007[0]/1-8{007[0]/0=\a}' $variable = new MARCspec('245^1'); echo $variable['field']['tag']; // '245' echo $variable['indicator']; // CK\MARCspec\IndicatorInterface echo $variable['indicator']['position']; // '1' $variable; // CK\MARCspec\MARCspecInterface echo $variable; // '245^1' $complex = new MARCspec('020$a{$q[0]~\pbk}{$c/0=\€|$c/0=\$}'); echo $complex['field']['tag']; // '020' $complex['subfields']; // Array $complex['subfields'][0]['tag']; // CK\MARCspec\SubfieldInterface echo $complex['subfields'][0]['tag']; // 'a' $complex['a'][0]['subSpecs'][0]['leftSubTerm']; // CK\MARCspec\MARCspecInterface echo $complex['a'][0]['subSpecs'][0]['leftSubTerm']; // '020$q[0]' echo $complex['a'][0]['subSpecs'][0]['operator']; // '~' $complex['a'][0]['subSpecs'][0]['rightSubTerm']; // CK\MARCspec\ComparisonStringInterface echo $complex['a'][0]['subSpecs'][0]['rightSubTerm']['comparable']; // 'pbk' echo $complex['a'][0]['subSpecs'][1][0]['leftSubTerm']; // '020$c/0' echo $complex['a'][0]['subSpecs'][1][0]['leftSubTerm']['c'][0]['charStart']; // 0 echo $complex['a'][0]['subSpecs'][1][0]['leftSubTerm']['c'][0]['charEnd']; // 0 echo $complex['a'][0]['subSpecs'][1][0]['leftSubTerm']['c'][0]['charLength']; // 1 echo $complex['a'][0]['subSpecs'][1][0]['operator']; // '=' echo $complex['a'][0]['subSpecs'][1][0]['rightSubTerm']['comparable']; // '€' echo $complex['a'][0]['subSpecs'][1][1]['leftSubTerm']; // '020$c/0' echo $complex['a'][0]['subSpecs'][1][1]['leftSubTerm']['c'][0]['charStart']; // 0 echo $complex['a'][0]['subSpecs'][1][1]['leftSubTerm']['c'][0]['charEnd']; // 0 echo $complex['a'][0]['subSpecs'][1][1]['leftSubTerm']['c'][0]['charLength']; // 1 echo $complex['a'][0]['subSpecs'][1][1]['operator']; // '=' echo $complex['a'][0]['subSpecs'][1][1]['rightSubTerm']['comparable']; // '$' // creating MARCspec // creating a new Field $Field = new Field('...'); // creating a new MARCspec by setting the Field $MARCspec = MARCspec::setField($Field); // creating a new Subfield $Subfield = new Subfield('a'); // adding the Subfield to the MARCspec $MARCspec->addSubfields($Subfield); // creating instances of MARCspec and ComparisonString $LeftSubTerm = new MARCspec('...$a/#'); $RightSubTerm = new ComparisonString(','); // creating a new SubSpec with instances above and an operator '=' $SubSpec = new SubSpec($LeftSubTerm,'=',$RightSubTerm); // adding the SubSpec to the Subfield $Subfield['subSpecs'] = $SubSpec; // whole MARCspec echo $MARCspec; // '...[0]$a{...$a/#-#=\,}'
ArrayAccess vs. Methods
MARCspec can be accessed like an immutable array with the following offsets or with its correponding methods (see source code for documentation of all methods).
Instances of MARCspec
| offset | method get | method set | type |
|---|---|---|---|
| field | getField | setField | Field |
| subfields | getSubfields | addSubfields | array[Subfield] |
| [subfield tag] | getSubfield | array[Subfield] | |
| indicator | getIndicator | setIndicator | Indicator |
Instances of Field
| offset | method get | method set | type |
|---|---|---|---|
| tag | getTag | string | |
| charStart | getCharStart | setCharStart | int |
| charEnd | getCharEnd | setCharEnd | int |
| charLength | getCharLength | int | |
| indexStart | getIndexStart | setIndexStart | int |
| indexEnd | getIndexEnd | setIndexEnd | int |
| indexLength | getIndexLength | int | |
| subSpecs | getSubSpecs | addSubSpecs | array[SubSpec]|array[array[SubSpec]] |
Instances of Subfield
| offset | method get | method set | type |
|---|---|---|---|
| tag | getTag | string | |
| charStart | getCharStart | setCharStart | int |
| charEnd | getCharEnd | setCharEnd | int |
| charLength | getCharLength | int | |
| indexStart | getIndexStart | setIndexStart | int |
| indexEnd | getIndexEnd | setIndexEnd | int |
| indexLength | getIndexLength | int | |
| subSpecs | getSubSpecs | addSubSpecs | array[SubSpec]|array[array[SubSpec]] |
Instances of Indicator
| offset | method get | method set | type |
|---|---|---|---|
| position | getPos | string | |
| subSpecs | getSubSpecs | addSubSpecs | array[SubSpec]|array[array[SubSpec]] |
Instances of ComparisonString
| offset | method get | type |
|---|---|---|
| raw | getRaw | string |
| comparable | getComprable | string |
Instances of SubSpec
| offset | method get | type |
|---|---|---|
| leftSubTerm | getLeftSubTerm | MARCspec|ComparisonString |
| operator | getOperator | string |
| rightSubTerm | getRightSubTerm | MARCspec|ComparisonString |
ck/php-marcspec 适用场景与选型建议
ck/php-marcspec 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74.16k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2014 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「MARCspec」 「MARC 21」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ck/php-marcspec 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ck/php-marcspec 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ck/php-marcspec 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
MARC Record handling tool for PHP
MARCspec adapter for File_MARC
Simple interface to parsing MARC records using File_MARC
A simple MARC21/XML parser
A Testsuite for MARCspec parsers
This php class converts an MARC output from Aleph to a XML file
统计信息
- 总下载量: 74.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-18