Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cloudflare D1 Database Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for edge/serverless Laravel hosting. If the roadmap includes running Laravel against Cloudflare D1 (edge deployments, Cloudflare-native stack, prototypes that must avoid managed MySQL/Postgres), this package is the "buy" path — full Eloquent, Query Builder, and Migrations support with artisan commands for import, schema dump, time travel, and health checks. Building an equivalent driver is weeks of work; this gets you to a working integration.
  • Architecture audit: transaction dependency. Because 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.
  • Read-heavy / global-read roadmap. The Worker driver's Sessions + automatic read/write splitting let SELECTs hit D1 global read replicas. This supports a concrete product decision: "serve read-heavy pages (catalogs, content, dashboards) from the edge; keep writes centralized."
  • Driver/hosting strategy. The REST vs. Worker split is itself a product decision: REST = zero infra but an extra HTTP hop per query (high latency); Worker = deploy a Cloudflare Worker proxy for low latency and Sessions/read-replication. This determines whether the app is viable for interactive UX or only batch/async workloads.
  • SLO and reliability posture. Circuit breaker + exponential-backoff retries are built in — but retries are intentionally scoped to SELECT/WITH only. This bounds how the team can promise consistency on writes and supports a "read-resilient, write-best-effort" product stance.
  • Cost modeling. D1 pricing is dramatically cheaper than managed RDBMS at low-to-moderate scale. This package makes a "cheap-first, migrate-later" launch strategy concrete and low-risk to try.

When to Consider This Package

Consider it when all of the following hold:

  • The Laravel app's data layer is SQLite-compatible — no dialect-specific SQL, no reliance on window functions beyond what D1 supports, no exotic Postgres/MySQL extensions.
  • The application is read-heavy or write-light (content, catalogs, dashboards, analytics dashboards, internal tools), and D1's single-writer concurrency is acceptable.
  • The team already has or is committing to Cloudflare credentials (API token, account ID, database ID), and can deploy a Cloudflare Worker if production latency matters — the REST driver is acceptable only for prototypes, backfills, or non-interactive jobs.
  • You can audit and eliminate DB::transaction() from critical paths, or already structure mutations to fit batch()/bulkInsert() semantics.
  • Data volume and query patterns fit D1's 100-statement batch limit and chunked (non-global) atomicity for bulkInsert().

Look elsewhere when:

  • Any core domain needs true ACID transactions (payments, inventory, ledgers). D1's no-op transactions are disqualifying without a redesign.
  • The app is write-heavy or latency-sensitive on writes — the HTTP-per-query model and single-writer constraint will dominate.
  • The organization standardizes on Postgres/MySQL, or existing reporting/BI tooling expects a managed RDBMS.
  • Operational maturity is required: the package is early (30 stars, 0 dependents, single maintainer, MIT). It is a "pilot/watch" adoption, not a "load-bearing core" adoption, unless you are prepared to fork/maintain.
  • You need transactions across chunks — bulkInsert() commits earlier chunks even if a later chunk fails; this is a documented behavior, not a bug, but it is a product constraint.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
thuraaung2493/laravel-rulecraft
cyberwizard/schedule-catchup
livetennisapi/livetennisapi-laravel
roundly-consulting/notifications-for-laravel
flightsadmin/bootstrap-starter-kit
lasserafn/laravel-intempus
likyly/sdk
tdt/input
coreation/php-shapefile
coreation/gisconverter
primix/widgets
primix/notifications
primix/actions
primix/tables
primix/details
primix/forms
primix/support
marcelgwerder/laravel-api-handler
firebrikdotcom/conveyor-laravel-broadcaster
kanata-php/conveyor-laravel-broadcaster