dhorrigan/capsule
Capsule is a Laravel/PHP package by Dan Horrigan that provides a lightweight way to encapsulate reusable application logic. It integrates cleanly with Laravel, helps keep code organized, and makes components easier to test, extend, and maintain across projects.
illuminate/database, which already ships Illuminate\Database\Capsule\Manager natively. The real product decision to evaluate is “do we standardize on Eloquent outside Laravel?” — this package is only the packaging around that answer.Adopt only if all of the following hold:
dhorrigan/capsule) and linked repository (philsturgeon/capsule) do not match. That mismatch is a supply-chain due-diligence item to resolve before any adoption.Look elsewhere if any of the following hold:
illuminate/database directly. It ships Illuminate\Database\Capsule\Manager, the maintained, first-party version of exactly this. A wrapper around a wrapper adds a dependency without adding capability. This is the default recommendation.One-liner: A tiny adapter that brings Laravel’s database layer to non-Laravel PHP code — cheap to try, but effectively unmaintained, so it should be a tactical spike, not a platform standard.
For executives: The license cost is zero and the integration cost is near zero, but the ownership cost is not. With zero stars and zero dependents, there is no community backing, no security-response process, and no guarantee of future compatibility. The recommendation is not to adopt this package as a standard. Instead, approve a short, time-boxed engineering spike; if Eloquent outside Laravel proves valuable, depend on illuminate/database directly with a pinned version. Budget assumption: we own the code either way, so we should own the smallest possible surface.
For engineering: The API is Capsule\Manager — familiar to anyone who has used Laravel, and the wrapper’s surface area is minimal, so an exit is cheap. Put it behind an internal repository/gateway interface (e.g. a DatabaseBootstrapper) so the ORM can be swapped without touching domain code. Swap the implementation to native Illuminate\Database\Capsule\Manager, remove the wrapper, pin the Illuminate version deliberately, and add a smoke test that asserts connection plus model hydration on every CI run. Instrument for the likely failure modes: Composer resolution conflicts blocking unrelated upgrades, dual-global-capsule class collisions routing queries to the wrong connection, hard failures on PHP minor upgrades, and connection leaks in CLI loops or long-lived workers (Swoole, RoadRunner, queue daemons).
The ask: A time-boxed evaluation (1–2 days), not a roadmap commitment. Success criteria: Eloquent models and migrations working against our target database in a non-Laravel context, with a documented exit path and a pinned dependency. If the spike succeeds, the deliverable is the internal abstraction plus the native Illuminate dependency — not this package.
How can I help you explore Laravel packages today?