Registry / database / php-wasm-sqlite

php-wasm-sqlite

JSON →
library0.1.0jsnpmunverified

SQLite extension loader for php-wasm, providing sqlite3 and pdo_sqlite extensions as shared libraries for PHP in WebAssembly. Current version 0.1.0. Ships TypeScript types. Resolves runtime version (e.g., php8.x-sqlite.so) and bundles libsqlite3.so. Lightweight alternative to building PHP with SQLite statically; works only with php-wasm runtime.

npm install php-wasm-sqlite
INSTALL
IMPORT
SIG · PHP-WASM-SQLITE
P
php-wasm-sqlite
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import sqlite from 'php-wasm-sqlite'
import { sqlite } from 'php-wasm-sqlite'
Default export is the sqlite shared library object.
PhpWeb
import { PhpWeb } from 'php-wasm/PhpWeb.mjs'
import PhpWeb from 'php-wasm'; import { PhpWeb } from 'php-wasm'
PhpWeb is a named export from the php-wasm package, not from php-wasm-sqlite. Use .mjs extension for ESM.
PhpWeb with sqlite
import { PhpWeb } from 'php-wasm/PhpWeb.mjs'; import sqlite from 'php-wasm-sqlite'; new PhpWeb({ version: '8.4', sharedLibs: [sqlite] })
new PhpWeb({ version: '8.4', sharedLibs: ['php-wasm-sqlite'] })
Pass the imported sqlite object, not a string.

Creates a PhpWeb instance with SQLite extensions loaded and checks that both sqlite3 and pdo_sqlite are enabled.

import { PhpWeb } from 'php-wasm/PhpWeb.mjs'; import sqlite from 'php-wasm-sqlite'; const php = new PhpWeb({ version: '8.4', sharedLibs: [sqlite], }); await php.run(`<?php var_dump( extension_loaded('sqlite3'), extension_loaded('pdo_sqlite') ); `);
Debug
Known issues
gotchaMust install both php-wasm and php-wasm-sqlite as dependencies.
fix
npm install php-wasm php-wasm-sqlite
affects: >=0.0.0
gotchaThe sqlite extension is loaded as a shared library; it will not work if php-wasm is built statically without SQLite support.
fix
Ensure php-wasm is built with WITH_SQLITE=dynamic or WITH_SQLITE=shared. Set in .php-wasm-rc.
affects: >=0.0.0
gotchaVersion of SQLite is determined by the bundled libsqlite3.so, which may differ from host system or other PHP builds.
fix
Check the shipped libsqlite3.so version inside the package.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: PhpWeb is not a constructor
Import Path: using wrong import for PhpWeb (e.g., from 'php-wasm' instead of 'php-wasm/PhpWeb.mjs').
fix
Change to: import { PhpWeb } from 'php-wasm/PhpWeb.mjs';
Error: Shared library not found: php8.x-sqlite.so
The version provided does not match a built .so file (e.g., version '8.0' may not be available).
fix
Use version '8.4' or another supported version. Check php-wasm documentation for available PHP versions.
Missing optional dependency: php-wasm
php-wasm is a peer dependency and must be installed separately.
fix
Run: npm install php-wasm
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
php-wasmrequiredpeer dependency; requires php-wasm runtime to load the extensions
Agent activity
8 hits · last 30 days
node
6
Resources
php-wasm-sqlite — npm install php-wasm-sqlite · libregistry