statamic/eloquent-driver
The Statamic Eloquent Driver lets you store Statamic content—entries, terms, assets, and more—in Laravel Eloquent models instead of flat files, making content queryable in your database while keeping Statamic’s familiar APIs and workflows.
Architecture fit. The package swaps Statamic's flat-file repositories for Eloquent-backed ones at a per-repository configuration seam (entries, terms, assets, globals, navigations, users). Blueprints, the Control Panel, template tags, and Statamic's public APIs stay intact — only persistence changes. For a TPM this is the rare infrastructure change with a genuinely small blast radius: it is a config-level increment, not a re-platforming, and it is reversible by reverting config and clearing the stache. The payoff is narrow and honest: relational querying, indexing, joins against application/CRM/analytics tables, and reuse of existing database backup, monitoring, and observability tooling.
Integration feasibility. High for teams already on Statamic + Laravel with an operated MySQL/Postgres instance. The path is composer require, publish config and migrations, php artisan migrate, run the per-repository importers (e.g. statamic:eloquent:import-entries), clear the stache, and flip one repositories.*.driver value at a time. Mixed drivers are supported, which means the realistic first milestone is "entries only," shipped to production with assets and globals still on disk. That gives a small blast radius, a clear debug signal, and a cheap rollback. The package adds no new infrastructure — no search cluster, broker, or hosted service — which is the core architectural argument in its favour.
Technical risk.
users repository is hazardous. A bad user import can lock operators out of the Control Panel. Migrate last, in staging first, with a one-line config rollback rehearsed.order column rather than inferred. Rows written by earlier versions or manual inserts that skipped order will sort arbitrarily after upgrade — backfill or re-import before trusting listings.Key questions to resolve before commitment.
users in scope at all?migrate --force in the release script, and is there a tested rollback path?Stack fit. Requires a Laravel app with Statamic and a relational database (MySQL, Postgres, or SQLite) the team already operates. It reuses existing migrations, backup policy, monitoring, and connection management. Database driver choice matters at the edges — JSON column behaviour, full-text search, and collation differ between SQLite and Postgres — so standardise on the production engine in staging.
Migration path. Phased, reversible, and validated at each step:
migrate against a production-shaped copy. Flip no drivers. Confirm migrations apply cleanly and record baseline metrics (listing render latency, import duration, DB size).order-dependent listings, and audit publish timestamps against known scheduled content.users last or never. Each step repeats flip → import → clear stache → validate → soak.Compatibility. Match the driver major to the Statamic major (v5.x aligns with Statamic 5). Inventory addons and custom code: anything querying through Statamic APIs is generally fine; anything reading Markdown files or filesystem paths will break. Multisite content, search indexes, queued jobs, and cached stache entries all need explicit verification. Extend the package's models rather than forking, so patch upgrades stay trivial.
Sequencing and deploy changes. Content migrations join the deploy script; decide whether content is seeded per environment, restored from production, or authored in place. RefreshDatabase plus factories becomes the content-fixture strategy — a genuine testing win. Rollback rehearsal belongs in the plan, not in the incident.
Exit criteria and rollback triggers (TPM-owned). Define them before the pilot: render latency on listings must not regress beyond an agreed threshold; import must complete within a maintenance window; zero ordering or timestamp defects in the validation sample; any users-repository failure aborts immediately. Track pilot metrics — listing render time, import duration, query latency on augmented pages, editorial incident count — so expansion is a data decision, not an opinion.
Maintenance. The team permanently owns content schema migrations, model extensions, and upgrade alignment with Statamic majors. Fold driver upgrades into the normal dependency cadence, but read release notes for data-affecting fixes: 5.12.3 changed order handling and corrected timezone-on-save, both of which imply post-upgrade data checks. Pin versions, extend rather than fork, and treat every Statamic upgrade as a paired driver upgrade.
Support. Thin ecosystem, no vendor SLA. Budget internal triage, maintain a regression test suite, and keep staging database-parity with production. Expect to be your own first-line support; upstream fixes exist but you cannot contract for response time.
Scaling. This is the point of the exercise: indexes, cursor pagination, aggregates, joins, and read replicas become available for content. But the database becomes the content hot path, so capacity planning, connection limits, and query review matter. Watch N+1 queries from augmentation, large import batches, and stache invalidation on publish — all are scaling failure modes that flat files did not have in the same form.
Failure modes to plan for.
users lockout blocking the Control Panel; migrate in staging first with config rollback ready.order values causing arbitrary sorting after the 5.12.3 upgrade; backfill before trusting listings.Ramp-up. Engineering effort is modest — the team already knows Eloquent — but new runbooks are required: content import, stache clearing, content backup and restore, environment seeding, and rollback. The larger ramp is editorial and stakeholder-facing: content no longer appears in pull requests, staging refreshes change shape, and review workflows must be redesigned. TPM actions: a timeboxed entries-only pilot with named success metrics and exit criteria, a written rollback procedure tested in staging, a comms plan for editors covering what changes about draft/review/publish, and a decision log entry covering schema ownership and the flat-file retention window. Treat success as measurable — faster listings, reliable ordering, correct timestamps, no content-loss incidents — and let that evidence, not the package's novelty, justify expanding beyond entries.
How can I help you explore Laravel packages today?