Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

pdo-cfd1

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdo-cfd1

PGlite connector for pdo & php-wasm.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

pdo-cfd1

pdo-cfd1 is the Cloudflare D1 PDO driver extension used by php-wasm.

This package exists mainly so custom php-wasm builds can vendor and compile the pdo_cfd1 extension. It does not ship a separate JavaScript entrypoint from this folder. At runtime, support is enabled by passing Cloudflare D1 bindings into the PHP runtime.

pdo_cfd1 requires PHP 8.1 or newer.

Runtime Setup

Pass your Worker's D1 bindings into the cfd1 object when you construct the runtime. Each key becomes a PDO target name inside PHP.

import { PhpWorker } from 'php-wasm/PhpWorker.mjs';

export default {
  async fetch(request, env) {
    const php = new PhpWorker({
      version: '8.4',
      cfd1: {
        mainDb: env.mainDb,
      },
    });

    await php.run(`<?php
      $pdo = new PDO('cfd1:mainDb');
      var_dump($pdo instanceof PDO);
    `);

    return new Response('ok');
  },
};

Querying D1 Through PDO

Once the binding is present, use cfd1:<bindingName> as the DSN:

await php.run(`<?php
  $pdo = new PDO('cfd1:mainDb');

  $select = $pdo->prepare(
    'SELECT PageTitle, PageContent FROM WikiPages WHERE PageTitle = ?'
  );

  $select->execute(['Home']);

  $page = $select->fetch(PDO::FETCH_ASSOC);
  var_dump($page);
`);

Scope

  • This is for php-wasm runtimes that execute in a Cloudflare Worker-compatible environment.
  • Most consumers of the published php-wasm packages do not import anything from this package directly.
  • If you are only using browser or Node runtimes, this extension is usually irrelevant.

Custom Builds

Enable the extension in .php-wasm-rc:

WITH_PDO_CFD1=1

Build-related variables:

  • WITH_PDO_CFD1: defaults to 0. Set it to 1 to compile the extension into a custom build.
  • PDO_CFD1_DEV_PATH: optional local checkout used instead of cloning the upstream repository during the build.

FAQs

Package last updated on 18 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts