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
Laravel Cloudflare D1

Laravel Cloudflare D1 Laravel Package

erimeilis/laravel-cloudflare-d1

Adds Cloudflare D1 as a native Laravel database connection, letting your app run queries against D1's serverless SQLite at the edge. Configure credentials, then use Eloquent and the query builder as usual to build edge-friendly apps.

View on GitHub
Deep Wiki
Context7

erimeilis/laravel-cloudflare-d1 is a Laravel package that connects your application to Cloudflare D1, Cloudflare's serverless SQLite database built for the edge. It integrates D1 as a native Laravel database connection, letting you run query builder and Eloquent operations against your D1 database with minimal configuration.

  • Adds a D1 database driver via Cloudflare's HTTP API
  • Supports Eloquent models, migrations, and raw queries
  • Configure with an account ID, database ID, and API token
  • Works with existing Laravel database connections and tooling
  • Ideal for edge-first, serverless Laravel deployments
Frequently asked questions about Laravel Cloudflare D1
What is erimeilis/laravel-cloudflare-d1 and what problem does it solve?
It is a Composer package that registers Cloudflare D1 as a database driver inside Laravel. D1 is Cloudflare's serverless SQLite database and it does not speak the MySQL or Postgres wire protocols, so a stock Laravel connection cannot reach it. This package bridges that gap so you can go through Laravel's database layer, query builder and Eloquent instead of hand-rolling calls to the D1 HTTP API.
How do I install laravel-cloudflare-d1 in a Laravel application?
Install it with Composer by running composer require erimeilis/laravel-cloudflare-d1. Laravel's package auto-discovery should register the service provider, so a manual entry in config/app.php is usually unnecessary. After installing, publish any configuration the README describes and add your Cloudflare account ID, D1 database ID and API token to your .env file.
How do I configure the Cloudflare D1 connection in config/database.php?
You add an entry to the connections array in config/database.php that uses this package's driver and supplies your Cloudflare credentials. Copy the exact key names and environment variables from the repository README rather than guessing, since they are defined by the package. Once the connection exists, set DB_CONNECTION to its name or select it explicitly with the connection() method.
Which Laravel and PHP versions does this package support?
The composer.json in the repository is the definitive source, because the constraints can change between tagged releases. Check the require and require-dev blocks before adding it to an existing project and confirm your PHP version satisfies what is declared. If you are on an older Laravel release, look for a tagged version whose constraints match your application.
Can I use Eloquent models and migrations with Cloudflare D1?
Eloquent runs on top of Laravel's database layer, so once the D1 connection is registered, ordinary model queries and the query builder should route through it. Migrations deserve extra care because D1 is SQLite-based and supports a narrower set of DDL and ALTER TABLE operations than MySQL or Postgres. Run your migrations against a real D1 database early so schema issues surface before you deploy.
What Cloudflare API token permissions does the D1 driver need?
The driver reaches D1 through Cloudflare's REST API rather than a direct socket, so it authenticates with an API token. Scope the token to the specific account and D1 database you are using instead of a broad global API key. Verify the exact permission names in the Cloudflare dashboard and cross-check them against the package README.
Is this driver fast enough for production, given D1 is reached over HTTP?
Each query is an HTTPS round trip to Cloudflare's API, so latency is higher than a MySQL or Postgres connection in the same datacenter, and the cost compounds with the number of queries per request. It fits low-to-moderate traffic apps, admin panels and edge workloads better than chatty, query-heavy applications. Before going live, measure your real query counts per request and consider caching or batching where it helps.
What SQLite and D1 limitations should I expect when using this driver?
Because D1 is built on SQLite, you inherit its type affinity rules, its limited ALTER TABLE support and its cap on bound parameters per statement. D1 also publishes limits on database size, query duration and request rates that you should compare against your workload. MySQL-only features such as stored procedures are not available, so plan an alternative for anything that depends on them.
How can I test an application that uses this driver without calling Cloudflare?
For unit and feature tests, point Laravel at an in-memory or file-based SQLite connection, whose dialect is close to D1's. That keeps the suite fast, deterministic and free of external credentials. Keep a separate integration test, run manually or in a gated CI job, for verifying the real D1 connection and its configuration.
What alternatives exist, and how do I check whether this package is maintained?
Other community packages offer similar Laravel-to-D1 bridges, and for a handful of queries you can call the D1 HTTP API directly with Laravel's HTTP client. Before adopting this one, review its releases, recent commit history and open issues on GitHub. Pin a version in composer.json and read the changelog on upgrade, which is good practice for any small driver package.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core