michaelmannucci/verseoftheday
A Laravel package for adding a daily Bible verse to your application. It offers a simple, configurable way to fetch and display the verse of the day in your views, APIs, or scheduled jobs, making it easy to build daily inspiration features without extra dependencies.
v1.1.0 adds Bible version support and defaults to NIV. Treat this as a behaviorally significant feature release: existing calls that do not specify a version will now resolve through the NIV default, while new code can opt into other translations.
Start by checking:
version(...), translation(...), request option, or config key).config/bible.php, for the default version and supported-version list.Minimal setup:
composer require <vendor>/<package>:^1.1
php artisan vendor:publish --tag=bible-config
php artisan config:clear
Set the default explicitly in .env if the app should not silently inherit NIV:
BIBLE_VERSION=NIV
First use case: render a verse using the configured default, then allow an override per request.
// Defaults to NIV via package config.
$verse = Bible::verse('John 3:16');
// Per-call override, using the package's actual version API.
$verse = Bible::version('ESV')->verse('John 3:16');
If the package exposes a helper or injected client instead of a facade, keep the same pattern: resolve the client, select a version, then fetch the passage.
Set one application default, then override deliberately. Put the default in config/env so staging and production are explicit. Avoid scattering 'NIV' literals through controllers.
// config/bible.php
return [
'default_version' => env('BIBLE_VERSION', 'NIV'),
// ...
];
Pass version as a request-level concern. For user-facing Bible readers, validate the requested version against the package's supported list before passing it to the client.
$data = $request->validate([
'version' => ['nullable', 'string', Rule::in(config('bible.versions', ['NIV']))],
'reference' => ['required', 'string'],
]);
$verse = Bible::version($data['version'] ?? config('bible.default_version'))
->verse($data['reference']);
Persist user preference separately from package config. Store the user's chosen version on the user/profile/settings table, then resolve it at the edge of the request.
$version = $user->bible_version ?: config('bible.default_version');
$passage = Bible::version($version)->verse($reference);
Cache per version and reference. Version support makes cache keys more important. Never cache a verse under a key that omits the translation.
$version = $user->bible_version ?: config('bible.default_version');
$passage = Cache::remember(
"bible:{$version}:{$reference}",
now()->addDay(),
fn () => Bible::version($version)->verse($reference)
);
Expose the effective version in API resources and view data. Clients and templates should know which translation produced the text.
return [
'reference' => $reference,
'version' => $version,
'text' => $passage->text,
];
Keep version selection out of domain logic. Resolve the version in controllers, form requests, jobs, or dedicated services, then pass a simple value object or string into the rest of the app.
Test with a fixed default. In phpunit.xml, set BIBLE_VERSION=NIV so tests do not depend on a developer's local .env. Add coverage for default resolution, explicit override, invalid version handling, and cache-key separation.
NIV, ESV, etc. are likely identifiers. Validate against the package's supported list rather than accepting arbitrary strings.php artisan config:clear prevents stale bible.default_version values in local and deployed environments.How can I help you explore Laravel packages today?