rootxs/sudobible
Composer 安装命令:
composer require rootxs/sudobible
包简介
Open source Bible API.
关键字:
README 文档
README
Open source Bible API.
Installation & Setup
Instantiate SudoBible with your database credentials, and optional translation preference (default translation is the World English Bible, a modern, public-domain, English translation):
$oBible = new \RootXS\SudoBible([ 'db_host' => 'localhost', 'db_user' => 'my_user', 'db_pass' => 'my_super_secure_password', 'db_name' => 'my_db', 'translation' => 'ASV', ]);
Call the following method once when first setting up, then delete this code once your tables have been created:
$oBible->install();
Leaving this code in your application won't break anything. It will just cause your application to make several superfluous database queries each time it runs. Therefore, it is recommended to run this once and then remove it from your code.
Alternatively, you can manually run the queries found in the queries directory.
Find the sub-directory for your database type (e.g., mysql) and first run the
create scripts, in order. Then run the insert scripts.
Basic usage
Get a single verse:
$oPassage = $oBible->verse('John', 3, 16);
Get an entire chapter:
$oPassage = $oBible->chapter('John', 3);
Get a passage (supply beginning & end verses):
$oPassage = $oBible->ref('John', 3, 16, 17); // John 3:16-17 $oPassage = $oBible->ref('Hebrews', 5, 11, 6, 2); // Hebrews 5:11-6:2
Get one or more verses based on a topic:
$aPassages = $oBible->topic('church'); // returns an array of all related passages $oPassage = $oBible->topic('church', true); // returns a single, random related passage
The SudoBiblePassage Object
verse(), chapter(), and ref() each return a SudoBiblePassage object
which contains the requested passage and provides utilities for manipulating it.
Printing the passage
The SudoBiblePassage object employs the __toString() magic method, allowing
you to simply echo or print the object.
echo $oBible->verse('John', 3, 16);
Output:
For God so loved the world, that he gave his one and only Son, that whoever believes in him should not perish, but have eternal life. (John 3:16)
Styling the passage
The SudoBiblePassage object provides a few methods for styling the string output.
$oPassage = $oBible->ref('John', 3, 16, 17) ->numberVerses() // adds verse numbers to the passage string ->useHTML(); // adds some HTML styling to the passage string echo $oPassage;
Output:
16 For God so loved the world, that he gave his one and only Son, that whoever believes in him should not perish, but have eternal life. 17 For God didn't send his Son into the world to judge the world, but that the world should be saved through him. (John 3:16-17)
All of the styling methods accept a boolean parameter, so you can switch the styling off if it was previously turned on:
$oPassage->numberVerses(false);
The boolean flag defaults to true, so if you just want to turn the feature "on,"
no parameter is necessary.
Navigating the passage
The SudoBiblePassage object also provides a mechanism for proceding beyond the chosen passage:
$oPassage = $oBible->verse('John', 3, 16); for ($i=0; $i<2; $i++) { echo $oPassage; $oPassage = $oPassage->nextVerse(); }
Deleting or refreshing the database
To delete the sudo_bible_* tables, run this once in your PHP code:
$oBible->uninstall();
Or, you can manually run the scripts found in queries/{DB_TYPE}/drop.
To refresh the tables (after an update to the SudoBible repo, for example), you can run this in your PHP:
$oBible->reinstall();
This simply combines uninstall() with install(). You may also manually run
the query scripts in drop, create, and insert, in that order.
rootxs/sudobible 适用场景与选型建议
rootxs/sudobible 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「topic」 「bible」 「scripture」 「verse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rootxs/sudobible 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rootxs/sudobible 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rootxs/sudobible 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse verse textual representation into book/chapter/verse ranges
A PSR-7 compatible library for making CRUD API endpoints
Firebase notifications for Laravel
A Fast Markdown Parser extended for Liturgy in PHP.
A simple way to load, read, and present texts from various source text libraries.
PHP utility classes for parsing and processing Bible references
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-23