0.08
Laravel 10
No release in over 2 years
Low commit activity in last 18 months
Laravel integration for Cloudflare Workers services.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

laravel/legacy-factories
^1.3
mockery/mockery
^1.5
phpunit/phpunit
^9.5.21

Runtime

doctrine/dbal
^3.6
saloonphp/laravel-http-sender
^1.2
 Project Readme

L1 - Cloudflare bindings for Laravel

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Extend your PHP/Laravel application with Cloudflare bindings.

This package offers support for:

πŸš€ Installation

You can install the package via Composer:

composer require renoki-co/l1

πŸ™Œ Usage

D1 with raw PDO

Though D1 is not connectable via SQL protocols, it can be used as a PDO driver via the package connector. This proxies the query and bindings to the D1's /query endpoint in the Cloudflare API.

use RenokiCo\L1\D1\D1Pdo;
use RenokiCo\L1\D1\D1PdoStatement;
use RenokiCo\L1\CloudflareD1Connector;

$pdo = new D1Pdo(
    dsn: 'sqlite::memory:', // irrelevant
    connector: new CloudflareD1Connector(
        database: 'your_database_id',
        token: 'your_api_token',
        accountId: 'your_cf_account_id',
    ),
);

D1 with Laravel

In your config/database.php file, add a new connection:

'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', ''),
        ],
    ],
]

Then in your .env file, set up your Cloudflare credentials:

CLOUDFLARE_TOKEN=
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_D1_DATABASE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The d1Β driver will proxy the PDO queries to the Cloudflare D1 API to run queries.

πŸ› Testing

Start the built-in Worker that simulates 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 alex@renoki.org instead of using the issue tracker.

πŸŽ‰ Credits