ck/file_marc_reference 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ck/file_marc_reference

Composer 安装命令:

composer require ck/file_marc_reference

包简介

MARCspec adapter for File_MARC

README 文档

README

Build Status Coverage Status

File_MARC_Reference is an extension to the famous MARC parser for PHP File_MARC. With File_MARC_Reference you can use MARCspec as an unified way to access MARC data. Besides it simplifies File_MARC a lot.

Installation

Installation can be done by using Composer. Just run

composer require ck/file_marc_reference

Usage

First require autoload.php

<?php
require("vendor/autoload.php");

Reading MARC 21 data from a file or string stays the same (see File_MARC - Reading MARC data):

// Retrieve a set of MARC records from a file
$records = new File_MARC('data.mrc');

// Iterate through the retrieved records
while ($record = $records->next())
{
 //...
}

Now if you want to reference data using a MARCspec you have to initialize a new File_MARC_Reference:

// Retrieve a set of MARC records from a file
$records = new File_MARC('data.mrc');

// Iterate through the retrieved records
while ($record = $records->next())
{
    $reference = new File_MARC_Reference('245$a',$record);
}

After you referenced the data three public attributes are available:

$reference = new File_MARC_Reference('245$a',$record);

// attribute data
$subfield = $reference->data[0];
print get_class($subfield);               // File_MARC_Subfield
print $subfield->getCode();               // a

// attribute content
print $reference->content[0];             // prints content of subfield a of field 245

// attribute cache
$field = $reference->cache['245'][0];
print get_class($field);                  // File_MARC_Data_Field
$subfield = $reference->cache['245$a'];
print get_class($subfield);               // File_MARC_Subfield

Let's see how we check dependencies with File_MARC if you have a task like: Reference to content of subfield "a" of field 306 if character with index position "0" of field 007 is either "m", "s" or "v".

Instead of writing ...

$fields_007 = $record->getFields('007');

$field_306 = $record->getField('306');

$subfields_a = false;

foreach($fields_007 as $field_007)
{
    $firstChar = substr($field_007->getData(),0,1);
    
    if(strpbrk($firstChar,"msv"))
    {
        $subfields_a = $field_306->getSubfields('a');
        break;
    }
}

if($subfields_a)
{
    foreach($subfields_a as $subfield_a)
    {
        echo $subfield_a->getData()."\n";
    }
}

... the same task with File_MARC_Reference:

    $reference = new File_MARC_Reference('306$a{007/0=\m|007/0=\s|007/0=\v}',$record);
    
    foreach($reference->content as $subfield_a)
    {
        echo $subfield_a."\n";
    }
    
    // interested in field 007? No problem!
    print get_class($reference->cache['007'][0]);       // File_MARC_Control_Field
    print $reference->cache['007/0'][0];                // prints the first char of first 007 field
    print $reference->cache['007/0'][1];                // prints the first char of second 007 field

ck/file_marc_reference 适用场景与选型建议

ck/file_marc_reference 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74.7k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ck/file_marc_reference 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-29