techwilk/bible-verse-parser
Composer 安装命令:
composer require techwilk/bible-verse-parser
包简介
Parse verse textual representation into book/chapter/verse ranges
关键字:
README 文档
README
Parse verse textual representation into book/chapter/verse ranges
Allows you to standardise many different people's bible passage/reference formats and gain programmatic access to them.
Demo
A demo of the library's parsing can usually be found at https://bible-verse-parser.techwilk.com/
The code for the demo is in public/.
Installation
-
Install through composer.
composer require techwilk/bible-verse-parser
-
Then create a parser
use TechWilk\BibleVerseParser\BiblePassageParser; $passageParser = new BiblePassageParser();
Use
Just pass in a string, and it will parse into an array of passages. Each range will be a separate object in the array.
Shorthand book abbreviations will be converted into full book names
/** @var BiblePassage[] */ $passages = $passageParser->parse('1 John 5:4-17, 19-21 & Esther 2');
Casting to string
foreach ($passages as $passage) { echo (string) $passage . PHP_EOL; }
outputs:
1 John 5:4-17
1 John 5:19-21
Esther 2
Custom formatting
Alternatively use the values yourself.
foreach ($passages as $passage) { echo "From {$passage->from()->book()->name()}"; echo " chapter {$passage->from()->chapter()}"; echo " verse {$passage->from()->verse()}"; echo ", to {$passage->to()->book()->name()}"; echo " chapter {$passage->to()->chapter()}"; echo " verse {$passage->to()->verse()}." . PHP_EOL; }
outputs:
From 1 John chapter 5 verse 4, to 1 John chapter 5 verse 17.
From 1 John chapter 5 verse 19, to 1 John chapter 5 verse 21.
From Esther chapter 2 verse 1, to Esther chapter 2 verse 23.
Integer notation
Ideal for storing in a database & querying with something like MySQL. The integer notation is the same as several other libraries, with book number in millions, chapter in thousands and verse as ones (1000000 * book) + (1000 * chapter) + verse.
foreach ($passages as $passage) { echo $passage->from()->integerNotation(); echo ' (' . (string)$passage->from() . ')' . PHP_EOL; echo $passage->to()->integerNotation(); echo ' (' . (string)$passage->to() . ')' . PHP_EOL; echo PHP_EOL; }
outputs:
62005004 (1 John 5:4)
62005017 (1 John 5:17)
62005019 (1 John 5:19)
62005021 (1 John 5:21)
17002001 (Esther 2:1)
17002023 (Esther 2:23)
Supported formats
We may add additional formats in the future (please open an issue if you use a format which isn't listed.)
Single verse
John 3:16
John 3v16
John 3vv16
John 3 v16
John 3.16
John 3 16
John c3 v16
John ch3 v16
John chapter 3 verse 16
Whole chapter
John 3
Combinations of the above / multiples
John 3, 4
John 3:16-18, 19-22
Gen 1:1; 4:26
John 3:16 & Isiah 22
Is 53: 1-6 & 2 Cor 5: 20-21
Deut 6: 4-9, 16-end & Luke 15: 1-10
1 Peter 2, 5 & Job 34
1 Peter 2:15-16, 18-20
1 John 3:1-4:12
Roadmap
Parse many formats into book / chapter / verse rangesValidate book namesTranslate abbreviated book names into full namesValidate chapter / verse is valid in a given bookPassages which span over chapter or book boundries- Ability to explode verse ranges into one object per verse
Badges
techwilk/bible-verse-parser 适用场景与选型建议
techwilk/bible-verse-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.77k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parse」 「bible」 「scripture」 「verse」 「Passage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 techwilk/bible-verse-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 techwilk/bible-verse-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 techwilk/bible-verse-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
yii2 xml request parser
Parse promotion arrays from the Wayne State University API
Parse use statements for a reflection object
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Yii2 Simple HTML Dom
统计信息
- 总下载量: 3.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-19