prevailexcel / laravel-bible
一个Laravel包,提供超过2500种圣经版本,支持1600多种语言,由API.Bible提供支持。
Requires
- guzzlehttp/guzzle: ^7.0.1
This package is auto-updated.
Last update: 2024-09-05 12:04:36 UTC
README
一个Laravel包,提供超过2500种圣经版本,支持1600多种语言,由API.Bible提供支持。
安装
需要PHP 5.4+或HHVM 3.3+以及Composer。
要获取Laravel Bible的最新版本,只需要求它
composer require prevailexcel/laravel-bible
或者将以下行添加到您的composer.json
文件的require块中。
"prevailexcel/laravel-bible": "1.0.*"
然后您需要运行composer install
或composer update
来下载它并更新自动加载器。
一旦安装了Laravel Bible,您需要注册服务提供者。打开config/app.php
文件,并将以下内容添加到providers
键中。
'providers' => [ ... PrevailExcel\Bible\BibleServiceProvider::class, ... ]
如果您使用的是
Laravel >= 5.5
,可以跳过此步骤,并转到配置
。
PrevailExcel\Bible\BibleServiceProvider::class
同时,以如下方式注册外观
'aliases' => [ ... 'Bible' => PrevailExcel\Bible\Facades\Bible::class, ... ]
配置
您可以使用此命令发布配置文件
php artisan vendor:publish --provider="PrevailExcel\Bible\BibleServiceProvider"
一个名为bible.php
的配置文件,其中包含一些合理的默认值,将被放置在您的config
目录中。
<?php return [ /** * API Key From API.Bible Dashboard * */ 'apiKey' => getenv('BIBLE_API_KEY'), /** * API.Bible Live URL * */ 'url' => "https://api.scripture.api.bible/v1", /** * This is the list of available Versions * */ 'versions' => [ [ 'name' => 'kjv', // King James Version 'id' => 'de4e12af7f28f599-02', ], [ 'name' => 'igbo', // Open Igbo Contemporary Bible 2020 'id' => 'a36fc06b086699f1-02', ], [ 'name' => 'rv', //Revised Standard Version 'id' => '40072c4a5aba4022-01', ], [ 'name' => 'yoruba', // Open Yoruba Contemporary Bible 2020 'id' => 'b8d1feac6e94bd74-01', ], [ 'name' => 'hausa', // Open Hausa Contemporary Bible 2020 'id' => '0ab0c764d56a715d-01' ] ], /** * This is the default Version * */ 'default' => getenv('BIBLE_DEFAULT_VERSION'), ];
用法
打开您的.env
文件,并添加您的API密钥和您想要使用的默认版本,如下所示
BIBLE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" BIBLE_DEFAULT_VERSION="kjv"
您必须注册或登录到您的API.Bible账户,并获取您的应用API密钥。
默认版本必须首先在您的config/bible.php
中设置。如果您使用的是像heroku这样的托管服务,请确保将上述详细信息添加到您的配置变量中。
现在您可以调用bible()
辅助函数或Bible::method()
外观。
<?php use Illuminate\Support\Facades\Route; use PrevailExcel\Bible\Facades\Bible; Route::get('/bible-verse', function () { request()->book = 'JHN'; request()->chapter = 3; request()->verse = 16; // You can set requests from your form return Bible::verse(); // or simply return Bible::verse(16, 3, 'JHN'); // You can pass to method directly }); Route::get('/bible-search', function () { request()->term = 'King solomon'; return bible()->search(); // You can also use the bible() helper. });
此包提供的其他一些流畅方法如下所示。
/** * This is the method to get the full list of availble bibles, you can copy the id of the version you want, alonside and name you want to call it and add it to your config/bible.php. * @returns array */ Bible::bibles(); /** * Alternatively, use the helper. */ bible()->bibles(); /** * This is the method to get a particular bible version. * Leave empty to use the default version * @param string|null $version * @return array */ Bible::bible(); /** * Alternatively, use the helper. */ bible()->bible('igbo'); /** * This is the method to get list of books in a particular bible version. * Leave empty to use the default version * @param string|null $version * @return array */ Bible::books('kjv'); /** * Alternatively, use the helper. */ bible()->books(); /** * This is the method to get a book from the bible. * @param string $book * @return array */ Bible::book('GEN'); /** * Alternatively, use the helper. */ bible()->book('MAT'); /** * This is the method to get a chapter from a book from the bible. * @param string $chapter * @param string $book * @return array */ Bible::chapter(23, 'LUK'); /** * Alternatively, use the helper. */ bible()->chapter(5, 'MAT'); /** * This is the method to get full list of verses of a chapter from a book from the bible. * @param string $chapter * @param string $book * @return array */ Bible::verses(23, 'LUK'); /** * Alternatively, use the helper. */ bible()->verses(5, 'MAT');
待办事项
- 添加全面测试
- 添加对音频圣经的支持
- 添加圣经章节
贡献
请随意fork此包,并通过提交拉取请求来贡献以增强功能。
如何感谢你?
为什么不给github仓库点个赞?我很乐意得到关注!为什么不分享这个仓库的链接到Twitter或HackerNews?传播一下!
别忘了在twitter上关注我!还可以查看我的medium页面,以获取有关Laravel的文章和教程在medium上关注我!
谢谢!Chimeremeze Prevail Ejimadu。
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。