https://github.com/tanduy03/cloudflare-d1-database
Add package and setup integration for Cloudflare D1 database - TanDuy03
https://github.com/tanduy03/cloudflare-d1-database
cloudflare d1 laravel
Last synced: 5 months ago
JSON representation
Add package and setup integration for Cloudflare D1 database - TanDuy03
- Host: GitHub
- URL: https://github.com/tanduy03/cloudflare-d1-database
- Owner: TanDuy03
- License: mit
- Created: 2024-08-21T11:01:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-10T12:19:37.000Z (10 months ago)
- Last Synced: 2025-05-08T18:47:34.614Z (5 months ago)
- Topics: cloudflare, d1, laravel
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# D1 - Cloudflare bindings for Laravel
[](https://github.styleci.io/repos/845491307)

[](https://packagist.org/packages/ntanduy/cloudflare-d1-database)
[](https://packagist.org/packages/ntanduy/cloudflare-d1-database)
[](https://packagist.org/packages/ntanduy/cloudflare-d1-database)
[](https://packagist.org/packages/ntanduy/cloudflare-d1-database)Integrate Cloudflare bindings into your PHP/Laravel application.
This package offers support for:
- [x] [Cloudflare D1](https://developers.cloudflare.com/d1)
## 🚀 Installation
```bash
composer require ntanduy/cloudflare-d1-database
```## 👏 Usage
### Integrate Cloudflare D1 with Laravel
Add a new connection in your `config/database.php` file:
```php
'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:
```bash
cd tests/worker
npm ci
npm run start
```In a separate terminal, run the tests:
``` bash
vendor/bin/phpunit
```## 🤝 Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## 🔒 Security
If you discover any security related issues, please email instead of using the issue tracker.
## 🎉 Credits
- [TanDuy03](https://github.com/TanDuy03)
- [All Contributors](../../contributors)