承接 parallel-oss/l1 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

parallel-oss/l1

最新稳定版本:1.0.9

Composer 安装命令:

composer require parallel-oss/l1

包简介

Laravel integration for Cloudflare Workers services.

README 文档

README

CI Latest Stable Version License

Extend your PHP/Laravel application with Cloudflare bindings.

This package offers support for:

🚀 Installation

You can install the package via Composer:

composer require parallel-oss/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 Parallel\L1\D1\D1Pdo;
use Parallel\L1\D1\D1PdoStatement;
use Parallel\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.

D1 compatibility notes

This package keeps D1 usage close to native Laravel/SQLite, while accounting for Cloudflare-specific runtime limits:

  • Multi-row INSERT queries are automatically chunked to D1's bind-parameter limit.
  • Statements above D1 limits that cannot be safely rewritten fail fast with explicit errors.
  • Transport and API error responses are normalized into stable PDO/Laravel exceptions.
  • Retry behavior is conservative by default (safe/read-only and explicitly idempotent-safe paths).

These constraints still require app-level design choices:

  • D1 SQL/statement limits (for example statement size, row/blob size, function argument limits).
  • Workload shaping for long-running writes/migrations (batching and index strategy).
  • Transaction expectations that differ from local SQLite when execution is remote/request-scoped.

See docs/d1-sqlite-compatibility.md for the full behavior matrix.

🐛 Testing

Run all tests (the built-in D1 worker is started automatically):

composer test

This starts the Worker that simulates the Cloudflare D1 API, runs PHPUnit, then stops the worker. The first run will install worker dependencies (npm ci in tests/worker) if needed.

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please open an issue on GitHub.

🎉 Credits

统计信息

  • 总下载量: 93
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 35
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-02-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固