ntanduy / cloudflare-d1-database
Easy configuration and setup for D1 Database connections in Laravel.
Fund package maintenance!
TanDuy03
Requires
- php: ^8.2
- doctrine/dbal: ^3.0|^4.0
- illuminate/cache: *
- illuminate/contracts: *
- illuminate/database: *
- illuminate/http: *
- saloonphp/laravel-http-sender: ^2.0|^3.0
- saloonphp/laravel-plugin: ^3.5
- saloonphp/saloon: ^3.10
Requires (Dev)
- laravel/legacy-factories: ^1.4
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.3
- pestphp/pest: ^2.35
Suggests
- ext-pdo: Extending the PDO driver for Cloudflare D1 is requireds.
This package is auto-updated.
Last update: 2024-12-10 12:19:40 UTC
README
Integrate Cloudflare bindings into your PHP/Laravel application.
This package offers support for:
🚀 Installation
composer require ntanduy/cloudflare-d1-database
👏 Usage
Integrate Cloudflare D1 with Laravel
Add a new connection in your config/database.php
file:
'connections' => [ 'd1' => [ 'driver' => 'd1', 'prefix' => '', 'database' => env('CLOUDFLARE_D1_DATABASE_ID', ''), 'api' => 'https://api.cloudflare.com/client/v4', 'auth' => [ 'token' => env('CLOUDFLARE_TOKEN', ''), 'account_id' => env('CLOUDFLARE_ACCOUNT_ID', ''), ], ], ]
Next, configure your Cloudflare credentials in the .env
file:
CLOUDFLARE_TOKEN=
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_D1_DATABASE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
The d1
driver will forward PDO queries to the Cloudflare D1 API to execute them.
🌱 Testing
Start the built-in Worker to simulate the Cloudflare API:
cd tests/worker
npm ci
npm run start
In a separate terminal, run the tests:
vendor/bin/phpunit
🤝 Contributing
Please see CONTRIBUTING for details.
🔒 Security
If you discover any security related issues, please email ng.tanduy261203@gmail.com instead of using the issue tracker.