ntanduy/cloudflare-d1-database
Use Cloudflare D1 as a native Laravel database driver with full Eloquent ORM, Query Builder, and migration support. Choose REST API or Worker connections, batch queries, bulk inserts, read replication, import and schema dump commands, time travel, retries, and circuit breaking. Requires PHP 8.2+ and...
beginTransaction(), commit(), rollBack(), and savepoints are no-ops on D1, any feature that relies on DB::transaction() or rollback semantics (payments, order placement, inventory decrements, multi-table writes) is a product risk. This package forces an explicit roadmap decision: either refactor those flows to use D1Connection::batch() (atomic per 100-statement chunk, not globally atomic) or keep them on a transactional RDBMS.SELECT/WITH only. This bounds how the team can promise consistency on writes and supports a "read-resilient, write-best-effort" product stance.Consider it when all of the following hold:
DB::transaction() from critical paths, or already structure mutations to fit batch()/bulkInsert() semantics.bulkInsert().Look elsewhere when:
bulkInsert() commits earlier chunks even if a later chunk fails; this is a documented behavior, not a bug, but it is a product constraint.To executives: "This is a low-cost path to running our Laravel app on Cloudflare's edge with a native Eloquent driver — no custom database layer, and it comes with ops commands (health checks, import, schema dump, point-in-time recovery) out of the box. It lets us launch cheap and global, but it trades away database-level transactions. Recommend we pilot it on a read-heavy, non-transactional surface (content/catalog/dashboard) rather than anything touching money or inventory."
To engineering: "It plugs D1 into Laravel as a first-class connection — Eloquent, Query Builder, Migrations, Seeding all work. Two drivers: REST (simple, but every query is an HTTP round-trip; fine for prototypes and batch jobs) and a Worker proxy (lower latency, required for Sessions and read/write splitting). Be explicit about the constraints: transactions are no-ops — use batch() for atomic multi-statement writes; bulkInsert() chunks at 100 statements and is only atomic per chunk; retries only fire on SELECT/WITH; the circuit breaker uses Laravel Cache, so don't use the database cache driver. Ship the Worker driver for anything user-facing."
Risk framing (both audiences): mature enough to evaluate, not yet to bet the company on — README, changelog, releases, CI badges, MIT license are all positives, but 30 stars / 0 dependents / single maintainer mean we should pilot, document our integration, and be ready to fork if needed. Scope the pilot to a read-heavy, transaction-free surface and treat the transaction audit as a hard gate before any broader rollout.
How can I help you explore Laravel packages today?