Download the PHP package rootxs/sudobible without Composer
On this page you can find all versions of the php package rootxs/sudobible. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sudobible
SudoBible
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):
Call the following method once when first setting up, then delete this code once your tables have been created:
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:
Get an entire chapter:
Get a passage (supply beginning & end verses):
Get one or more verses based on a topic:
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.
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.
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:
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:
Deleting or refreshing the database
To delete the sudo_bible_*
tables, run this once in your PHP code:
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:
This simply combines uninstall()
with install()
. You may also manually run
the query scripts in drop
, create
, and insert
, in that order.