@kirigami/phpext-pgsql
v0.1.2
Published
Kirigami PHP.wasm shared extension: pgsql (JSPI side module, see @kirigami/php-wasm)
Maintainers
Readme
@kirigami/phpext-pgsql
pg_*() for Kirigami PHP.wasm — as a standalone, on-demand WASM side module.
Built for the Kirigami static site generator's PHP runtime, @kirigami/php-wasm.
Overview
@kirigami/phpext-pgsql is PHP's own ext/pgsql — unmodified upstream
source, straight from the PHP-8.5.11 tag — compiled independently of the
core php.wasm into a JSPI WASM side module (Kirigami's mode: shared
extension model). Install it and @kirigami/php-wasm picks it up
automatically at startup — no manual wiring, no core rebuild.
- ✅ Real
ext/pgsql:pg_connect,pg_query,pg_fetch_assoc, the full documented PHP API — not a reimplementation - ✅ Linked against a vendored, Emscripten-cross-compiled libpq 18.6 (PostgreSQL's own client library, static build)
- ⚠️ No SSL/TLS support yet in this build (plain connections work fully)
- ✅ JSPI only, Node.js only — matches
@kirigami/php-wasm's own target - ✅ Verified end-to-end: a real connection attempt exercises libpq's actual
network code path (not just a successful
dlopen)
Built by php-wasm-compiler,
which also documents the full build pipeline and architecture decisions.
Part of the Kirigami project ecosystem.
Table of contents
Requirements
- Node.js
>= 24.0.0 @kirigami/php-wasm(peer — this package has nothing to load it into on its own)
Installation
npm install @kirigami/phpext-pgsqlThat's it — @kirigami/php-wasm scans its own dependencies for
@kirigami/phpext-* packages at startup and loads whatever it finds.
Usage
No JS-side API of its own — once installed, the extension is just there in PHP:
<?php
$conn = pg_connect('host=localhost dbname=mydb user=postgres');
$result = pg_query($conn, 'SELECT 1');
var_dump(pg_fetch_assoc($result));Extension details
| | |
| --- | --- |
| PHP extension | ext/pgsql, unmodified, from the PHP-8.5.11 tag |
| PHP version(s) shipped | 8.5 |
| Native library | libpq 18.6 (static, bundled with libpgport/libpgcommon) |
| Build mode | mode: shared (JSPI side module) — see @kirigami/php-wasm's mode: static core for the always-on extension set instead |
| Patches | None — ext/pgsql's own PHP-facing API needed no changes; only the build configuration was adapted (a few libpq feature-detection checks pre-seeded to work around an unreliable cross-compile probe) |
| Build options | No SSL/TLS support yet (--without-openssl on the vendored libpq) |
Contents
*.so— one JSPI side module per PHP version listed above.manifest.json— extension metadata (name, per-version artifact paths, ini/env directives) consumed by@php-wasm/universal'sresolvePHPExtension().index.js(+index.d.ts) — default-exportsregister(phpVersion), resolving this package's artifact ready to feed into@php-wasm/universal'swithResolvedPHPExtensions(). This is what@kirigami/php-wasm's auto-loader calls — install the package and it's picked up automatically.package.json'skirigamifield —{ type: "extension", phpVersions, minVersion, vendorLib: { name, version }, buildHash }, mirroring the samekirigamimetadata convention every@kirigami/plugin-<name>package carries.minVersionis the exact PHP patch version this build was compiled/tested against (not a@kirigami/php-wasmsemver).
Compiled by php-wasm-compiler's
compile/cli.mjs compile-extension — see that repo's CLAUDE.md for the
full build/versioning story.
License
GPL-2.0-or-later, the license of php-wasm-compiler's build pipeline, which comes from WordPress Playground (see its NOTICE.md). The extension's own source, php-src's ext/pgsql, is under the PHP License 3.01.
Author
Maxime Larrivée-Roy, 2026
