PHPackages                             prismdb/client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. prismdb/client

ActiveLibrary[Database &amp; ORM](/categories/database)

prismdb/client
==============

Pure-PHP client for PrismDB over the binary wire protocol (no extension required).

v0.2.0(1mo ago)10Apache-2.0PHPPHP &gt;=8.1

Since Jun 14Pushed 3w agoCompare

[ Source](https://github.com/HafizMMoaz/prism-db-php)[ Packagist](https://packagist.org/packages/prismdb/client)[ Docs](https://github.com/HafizMMoaz/prism-db/tree/main/sdks/php)[ RSS](/packages/prismdb-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (3)Used By (0)

prismdb/client (PHP)
====================

[](#prismdbclient-php)

A **pure-PHP** client for [PrismDB](https://github.com/HafizMMoaz/prism-db), speaking the binary wire protocol directly over a TCP (or TLS) stream. No PHP extension required beyond the standard `sockets`/`openssl` streams that ship with PHP.

> Implements `docs/specs/wire-protocol.md`. The byte layouts are kept in lockstep with the Rust `prism-protocol` crate and the reference Node SDK.

Install
-------

[](#install)

```
composer require prismdb/client
```

Requires PHP ≥ 8.1.

Quick start
-----------

[](#quick-start)

```
use PrismDb\Client;
use PrismDb\Q;
use PrismDb\U;

$db = Client::connect(host: '127.0.0.1', port: 4444, username: 'admin', password: 'admin');

// SQL
$db->sql('CREATE TABLE users (id BIGINT PRIMARY KEY, name TEXT, age BIGINT)');
$db->sql("INSERT INTO users VALUES (1,'alice',30),(2,'bob',25)");
$res = $db->sql('SELECT name, age FROM users WHERE age >= 30 ORDER BY age');
foreach ($res->rows as $row) echo "{$row['name']} {$row['age']}\n";

// Key/value
$db->kv->put('sessions', 'sid-1', 'payload');
$v = $db->kv->get('sessions', 'sid-1');           // string|null

// Documents, with query operators
$db->doc->insertOne('people', ['name' => 'carol', 'age' => 41, 'city' => 'NYC']);
$adults = $db->doc->find('people', Q::and(Q::eq('city', 'NYC'), Q::gt('age', 30)));

// A transaction is atomic across all three models
$db->begin();
$db->sql("INSERT INTO users VALUES (3,'dave',50)");
$db->kv->put('sessions', 'sid-2', 'tx');
$db->commit();                                     // or $db->abort()

$db->close();
```

API
---

[](#api)

### `Client::connect(host, port, username, password, database, useTls, tls, ...)`

[](#clientconnecthost-port-username-password-database-usetls-tls-)

Performs the `Hello`/`Auth` handshake. Omit `username` to skip authentication. Pass `useTls: true` (with optional `tls:` stream SSL context options) for TLS. On a multi-database server, pass `database:` to select it at connect; otherwise run `$db->sql('USE ')` yourself.

### SQL — `$db->sql(string $text, array $params = [], bool $returnRows = true)`

[](#sql--db-sqlstring-text-array-params---bool-returnrows--true)

Returns a `SqlResult` with `->columns`, `->rows` (associative arrays keyed by column name), `->raw` (cells in column order), and `->affectedRows` (int).

### KV — `$db->kv`

[](#kv--db-kv)

`get(ns, key): ?string`, `put(ns, key, value)`, `delete(ns, key)`. Keys and values are byte strings.

### Documents — `$db->doc`

[](#documents--db-doc)

`insertOne` / `insertMany` (return the assigned `ObjectId`s), `find` / `findOne`, `count`, `updateOne` / `updateMany`, `deleteOne` / `deleteMany`. Build filters with `Q` and updates with `U`:

```
Q::all();
Q::eq('f', $v); Q::ne; Q::gt; Q::lt; Q::gte; Q::lte;
Q::in('f', [$a, $b]); Q::nin('f', [$a, $b]);
Q::exists('f', true);
Q::and($a, $b); Q::or($a, $b); Q::not($a);

$db->doc->updateOne('people', Q::eq('name', 'carol'), [
    U::set('city', 'Boston'),
    U::inc('age', 1),
    U::unset('temp'),
]);
```

### Transactions — `$db->begin(bool $readOnly = false)`, `$db->commit(int $idempotencyKey = 0)`, `$db->abort()`

[](#transactions--db-beginbool-readonly--false-db-commitint-idempotencykey--0-db-abort)

One `Client` is one server session, so calls between `begin()` and `commit()` run in that transaction.

### Value mapping

[](#value-mapping)

PHP → wire: `null`→Null, `bool`→Bool, `int`→Int64, `float`→Double, `string`→Str, `DateTimeInterface`→Timestamp, `ObjectId`→ObjectId. PHP has no separate byte type, so a plain string is text; use `Prism::binary($bytes)` for a BLOB and `Prism::int32($n)` / `Prism::float64($n)` / `Prism::timestamp($us)` to force the other wire types. Integers at or above 2^63 round-trip as negative PHP ints.

Develop
-------

[](#develop)

```
php tests/run.php          # unit tests (no server, no composer install needed)

# end-to-end against a running server:
prismd run ./data 127.0.0.1:4444
PRISM_HOST=127.0.0.1 PRISM_PORT=4444 php examples/quickstart.php
```

Status / limitations
--------------------

[](#status--limitations)

- Streamed (multi-frame) SQL/document results are not yet reassembled.
- KV `range`/`scan` are follow-ups.
- The client is synchronous; one `Client` owns one connection.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance93

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1361450b81d8000640ce2030f715fbc192a64598a434f4ec6d42972dde2b4b50?d=identicon)[hafizmmoaz](/maintainers/hafizmmoaz)

---

Top Contributors

[![HafizMMoaz](https://avatars.githubusercontent.com/u/103947442?v=4)](https://github.com/HafizMMoaz "HafizMMoaz (1 commits)")

---

Tags

clientdatabasesqldriverprismdocumentKey valuemulti-modelprismdb

### Embed Badge

![Health badge](/badges/prismdb-client/health.svg)

```
[![Health](https://phpackages.com/badges/prismdb-client/health.svg)](https://phpackages.com/packages/prismdb-client)
```

###  Alternatives

[basho/riak

Official Riak client for PHP

158248.3k7](/packages/basho-riak)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

62414.3k11](/packages/rah-danpu)[mroosz/php-cassandra

A pure-PHP client for Apache Cassandra and ScyllaDB with support for CQL binary protocol v3, v4 and v5 (Cassandra 2.1+ incl. 3.x-5.x; ScyllaDB 6.2 and 2025.x), synchronous and asynchronous APIs, prepared statements, batches, result iterators, object mapping, SSL/TLS, and LZ4 compression.

217.4k3](/packages/mroosz-php-cassandra)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
