Download the PHP package eukras/koinos without Composer
On this page you can find all versions of the php package eukras/koinos. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package koinos
koinos
A PHP library and composer package for working with:
- Biblical references in texts and databases, and
- Classical and Koine Greek text in Unicode.
Κοινός means 'common' in Ancient Greek. This package contains a number of reusable services and utilities from the Hexapla project.
Installation
You will need PHP >=5.4 and phpunit >=4.0.
In composer.json
:
Tests
The tests are the best documentation for developers.
Library data files
In each file the CSV lines specify id, library-name, name, short-name, handle, reference-depth, aliases, total-chapters.
- Handles are the short names used in URIs, e.g.
Romans 1
has handlerom+1
. - Normal books like 1 Corinthians are reference depth 2 (chapter:verse), but single-chapter books like Philemon are identified by verse only, so have a reference depth of 1.
Service\ReferenceManager and Utility\Reference
The ReferenceManager is use to construct, manipulate and format References.
Examples
Initialise the ReferenceManager as follows:
Libraries are easy to create: just add Resources/library/$library/books.csv
(see above), and pass $library
as a constructor argument.
The ReferenceManager handles most Reference operations.
$matt28
is now a Reference
object.
You will normally want to work with complex human-readable reference strings:
In this example $ref1
generates identically to $ref2
. Adjacent verse ranges
are combined together into a standard reference. Koinos does not know or care
how many verses are in a given chapter, though; internally, full-chapter links
are treated as Book 1:1-999.
All this together allows HTML links to be generated easily, though in a
framework you would most likely plug $rm->getHandle($ref)
into a route.
Being able to generate links allows them to be auto-replaced in text:
The scanner for matching links in text will identify if they exist in parallels, that is, if references are separated by a pipe character, e.g. "The Psalms Ps 14 | Ps 53 are the same." See the test suite for examples.
Utility\Reference Internals
Internal working is done with quadruples of [book, section, chapter, verse]
;
In $ref1
, 1cor is book #107, and has two-level referencing (c:v), so the
section number is always 1. Every quadruple becomes an UNSIGNED INT(12)
for
SQL (see below).
Query | Quadruple | Index |
---|---|---|
1 Cor 16:1 | [107, 1, 16, 1] | 107001016001 |
This makes it easy to efficiently index and match references and ranges:
The only gotcha is that, in PHP, these numbers must be treated as a strings, or
cast to (double)
: 12 digits exceed PHP's integer length. References are
usually manipulated as quadruples though, which are regular integers 1-999.
Utility\Greek
The Greek utility performs simple manipulation and scanning of Greek text:
Initialise without arguments:
This performs romanization, and offers some Unicode convenience wrappers.
Here's how it would be used to scan the structure of Psalm 116 (LXX) -- in Hexapla this is used to save texts word-by-word into a database.
For each word, let's grab its book/chapter/verse numbers (BCV), then paragraph/sentence/word numbers (PSW), and then any leading or trailing punctuation. (Psalms are book 227.)
See the class and Test suites for more.