PHPackages                             muninndb/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. muninndb/client

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

muninndb/client
===============

Official PHP SDK for MuninnDB — the cognitive memory database

v0.2.3(2mo ago)201MITPHPPHP &gt;=8.1

Since Feb 26Pushed 1mo agoCompare

[ Source](https://github.com/scrypster/muninndb-php)[ Packagist](https://packagist.org/packages/muninndb/client)[ RSS](/packages/muninndb-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

MuninnDB PHP SDK
================

[](#muninndb-php-sdk)

Official PHP client for [MuninnDB](https://github.com/scrypster/muninndb) — the cognitive memory database.

Framework-agnostic. Works in WordPress, Laravel, CodeIgniter, or plain PHP scripts with zero framework dependencies.

Features
--------

[](#features)

- All 24 MuninnDB REST API operations
- Typed response objects with readonly properties (PHP 8.1+)
- Clean named-argument API
- Automatic retry with exponential backoff on 5xx / connection errors
- Server-Sent Events (SSE) streaming via iterable `SseStream`
- PSR-4 autoloading, Composer-ready
- Native `curl` only — no Guzzle, no framework coupling

Requirements
------------

[](#requirements)

- PHP 8.1+
- `ext-curl`
- `ext-json`

Installation
------------

[](#installation)

```
composer require muninndb/client
```

Quick Start
-----------

[](#quick-start)

```
use MuninnDB\MuninnClient;

$client = new MuninnClient(
    baseUrl: 'http://127.0.0.1:8476',
    token: 'your-api-token',
);

// Write a memory
$result = $client->write(
    content: 'PHP 8.1 introduced readonly properties and fibers.',
    concept: 'PHP 8.1 Features',
    tags: ['php', 'language'],
);
echo $result->id;

// Recall by context
$activated = $client->activate(context: ['What changed in PHP 8?']);
foreach ($activated->activations as $item) {
    echo "{$item->concept}: {$item->score}\n";
}

// Read back
$engram = $client->read($result->id);
echo $engram->content;
```

Framework Examples
------------------

[](#framework-examples)

### WordPress

[](#wordpress)

```
// In your plugin file
require_once __DIR__ . '/vendor/autoload.php';
use MuninnDB\MuninnClient;

$client = new MuninnClient(token: get_option('muninndb_token'));
$result = $client->write(content: get_the_content(), concept: get_the_title());
update_post_meta(get_the_ID(), '_muninn_id', $result->id);
```

### Laravel

[](#laravel)

```
// In a service provider, controller, or anywhere
$client = new \MuninnDB\MuninnClient(
    baseUrl: config('muninndb.url'),
    token: config('muninndb.token'),
);

// In a controller
public function search(Request $request)
{
    $result = $this->client->activate(
        context: [$request->input('query')],
        limit: 20,
    );
    return response()->json($result->activations);
}
```

### CodeIgniter

[](#codeigniter)

```
// In a controller or library
$client = new \MuninnDB\MuninnClient(
    baseUrl: config('MuninnDB')->url,
    token: config('MuninnDB')->token,
);

$stats = $client->stats();
echo "Total engrams: {$stats->totalEngrams}";
```

### Vanilla PHP

[](#vanilla-php)

```
require_once __DIR__ . '/vendor/autoload.php';

$client = new \MuninnDB\MuninnClient(token: 'my-secret-token');

$client->write(
    content: 'Meeting notes from Monday standup.',
    concept: 'Standup Notes',
    vault: 'work',
    tags: ['meetings', 'standup'],
);
```

Full API Reference
------------------

[](#full-api-reference)

### Constructor

[](#constructor)

```
$client = new MuninnClient(
    baseUrl: 'http://127.0.0.1:8476', // Server URL
    token: '',                        // Bearer token
    timeout: 5.0,                     // Request timeout in seconds
    maxRetries: 3,                    // Retry count on 5xx / connection errors
    retryBackoff: 0.5,               // Base backoff delay (doubles each retry)
);
```

### Core CRUD

[](#core-crud)

#### `write(...)` — Write a single engram

[](#write--write-a-single-engram)

```
$response = $client->write(
    content: 'The actual memory content.',
    concept: 'A short label',
    vault: 'default',
    tags: ['tag1', 'tag2'],
    confidence: 0.8,
    stability: 0.5,
    memoryType: 'episodic',
    typeLabel: 'note',
    summary: 'Optional summary.',
    entities: ['entity1'],
    relationships: [['source' => 'id1', 'target' => 'id2', 'rel_type' => 'related']],
);
// Returns: WriteResponse { id, createdAt, hint }
```

#### `writeBatch(...)` — Write up to 50 engrams

[](#writebatch--write-up-to-50-engrams)

```
$response = $client->writeBatch([
    ['content' => 'First memory', 'concept' => 'Concept A'],
    ['content' => 'Second memory', 'concept' => 'Concept B'],
]);
// Returns: BatchWriteResponse { results: BatchWriteResult[] }
```

#### `read(id, vault)` — Read a single engram

[](#readid-vault--read-a-single-engram)

```
$engram = $client->read('engram-id-here');
// Returns: Engram { id, vault, concept, content, tags, confidence, ... }
```

#### `forget(id, vault, hard)` — Soft or hard delete

[](#forgetid-vault-hard--soft-or-hard-delete)

```
$client->forget('engram-id', hard: true);
```

#### `activate(...)` — Recall by context

[](#activate--recall-by-context)

```
$response = $client->activate(
    context: ['search terms', 'or phrases'],
    vault: 'default',
    threshold: 0.3,
    limit: 10,
    maxHops: 2,
    profile: 'creative',
    includeWhy: true,
    briefMode: true,
);
// Returns: ActivateResponse { queryId, totalFound, activations, latencyMs, brief }
```

#### `link(...)` — Associate two engrams

[](#link--associate-two-engrams)

```
$client->link(
    sourceId: 'id-a',
    targetId: 'id-b',
    relType: 'supports',
    weight: 0.9,
);
```

### Extended Operations

[](#extended-operations)

#### `evolve(id, newContent, reason, vault)` — Update content

[](#evolveid-newcontent-reason-vault--update-content)

```
$response = $client->evolve('engram-id', 'Updated content here.', 'Corrected typo');
```

#### `consolidate(ids, mergedContent, vault)` — Merge engrams

[](#consolidateids-mergedcontent-vault--merge-engrams)

```
$response = $client->consolidate(
    ids: ['id-1', 'id-2', 'id-3'],
    mergedContent: 'Combined knowledge from all three.',
);
// Returns: ConsolidateResponse { id, archived, warnings }
```

#### `decide(decision, rationale, alternatives, evidenceIds, vault)` — Record a decision

[](#decidedecision-rationale-alternatives-evidenceids-vault--record-a-decision)

```
$response = $client->decide(
    decision: 'Use PostgreSQL for the project',
    rationale: 'Better JSON support and mature ecosystem',
    alternatives: ['MySQL', 'SQLite'],
    evidenceIds: ['research-id-1', 'benchmark-id-2'],
);
```

#### `restore(id, vault)` — Recover a deleted engram

[](#restoreid-vault--recover-a-deleted-engram)

```
$response = $client->restore('deleted-engram-id');
// Returns: RestoreResponse { id, concept, restored, state }
```

#### `traverse(startId, maxHops, maxNodes, relTypes, vault)` — Graph walk

[](#traversestartid-maxhops-maxnodes-reltypes-vault--graph-walk)

```
$response = $client->traverse(
    startId: 'root-engram-id',
    maxHops: 3,
    maxNodes: 50,
    relTypes: ['supports', 'contradicts'],
);
// Returns: TraverseResponse { nodes, edges, totalReachable, queryMs }
```

#### `explain(engramId, query, vault)` — Score breakdown

[](#explainengramid-query-vault--score-breakdown)

```
$response = $client->explain('engram-id', query: ['why this result?']);
// Returns: ExplainResponse { engramId, finalScore, components, profile }
```

#### `setState(id, state, reason, vault)` — Change workflow state

[](#setstateid-state-reason-vault--change-workflow-state)

Valid states: `planning`, `active`, `paused`, `blocked`, `completed`, `cancelled`, `archived`

```
$response = $client->setState('engram-id', 'completed', reason: 'Task finished');
```

#### `listDeleted(vault, limit)` — List soft-deleted engrams

[](#listdeletedvault-limit--list-soft-deleted-engrams)

```
$response = $client->listDeleted(limit: 50);
// Returns: ListDeletedResponse { engrams: DeletedEngram[] }
```

#### `retryEnrich(id, vault)` — Re-run enrichment

[](#retryenrichid-vault--re-run-enrichment)

```
$response = $client->retryEnrich('engram-id');
```

#### `contradictions(vault)` — Detected contradictions

[](#contradictionsvault--detected-contradictions)

```
$response = $client->contradictions();
// Returns: ContradictionsResponse { contradictions: ContradictionItem[] }
```

#### `guide(vault)` — Human-readable vault guide

[](#guidevault--human-readable-vault-guide)

```
$text = $client->guide();
```

### Query &amp; List

[](#query--list)

#### `stats(vault)` — Vault statistics

[](#statsvault--vault-statistics)

```
$stats = $client->stats();
echo "Engrams: {$stats->totalEngrams}, Links: {$stats->totalLinks}";
```

#### `listEngrams(vault, limit, offset)` — Paginated engram list

[](#listengramsvault-limit-offset--paginated-engram-list)

```
$response = $client->listEngrams(limit: 50, offset: 100);
foreach ($response->engrams as $item) {
    echo "{$item->id}: {$item->concept}\n";
}
```

#### `getLinks(id, vault)` — Get an engram's associations

[](#getlinksid-vault--get-an-engrams-associations)

```
$links = $client->getLinks('engram-id');
// Returns: AssociationItem[]
```

#### `listVaults()` — List all vaults

[](#listvaults--list-all-vaults)

```
$vaults = $client->listVaults();
// Returns: string[]
```

#### `session(vault, since, limit, offset)` — Session activity log

[](#sessionvault-since-limit-offset--session-activity-log)

```
$response = $client->session(since: '2025-01-01T00:00:00Z');
foreach ($response->entries as $entry) {
    echo "{$entry->action}: {$entry->concept}\n";
}
```

### Streaming &amp; Health

[](#streaming--health)

#### `subscribe(vault, pushOnWrite)` — SSE subscription

[](#subscribevault-pushonwrite--sse-subscription)

```
foreach ($client->subscribe('default') as $event) {
    echo "Event: {$event->event}, Engram: {$event->engramId}\n";
    // Break when you've had enough
}
```

#### `health()` — Health check

[](#health--health-check)

```
$h = $client->health();
echo $h->status; // "ok"
```

Error Handling
--------------

[](#error-handling)

All errors throw exceptions extending `MuninnDB\Exceptions\MuninnException`:

ExceptionHTTP StatusWhen`AuthException`401Invalid or missing token`NotFoundException`404Engram / resource not found`ValidationException`400, 422Invalid request body`ConflictException`409Conflicting operation`ServerException`5xxServer-side error (after retries)`ConnectionException`—curl connection failure`TimeoutException`—Request exceeded timeout```
use MuninnDB\Exceptions\NotFoundException;
use MuninnDB\Exceptions\AuthException;

try {
    $engram = $client->read('nonexistent-id');
} catch (NotFoundException $e) {
    echo "Not found: {$e->getMessage()}";
} catch (AuthException $e) {
    echo "Auth failed — check your token";
}
```

Configuration
-------------

[](#configuration)

All configuration is done through the constructor — no config files, no environment variable magic:

```
$client = new MuninnClient(
    baseUrl: getenv('MUNINN_URL') ?: 'http://127.0.0.1:8476',
    token: getenv('MUNINN_TOKEN') ?: '',
    timeout: 10.0,
    maxRetries: 5,
    retryBackoff: 1.0,
);
```

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance88

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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

Unknown

Total

1

Last Release

82d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f97fbebdc600b7f91e567433215756ecd62a7d0b79f5ccb82ad47e90088c81df?d=identicon)[Scrypster](/maintainers/Scrypster)

---

Top Contributors

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

---

Tags

sdkdatabaseaimemorycognitivemuninndb

### Embed Badge

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

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

###  Alternatives

[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[kreait/laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

1.3k16.5M42](/packages/kreait-laravel-firebase)[morrislaptop/firestore-php

Firestore SDK for PHP without gRPC

6928.6k1](/packages/morrislaptop-firestore-php)[helgesverre/milvus

PHP Client for the Milvus Rest API

306.2k](/packages/helgesverre-milvus)[codewithkyrian/chromadb-laravel

ChromaDB Laravel is a Laravel client for the Chroma Open Source Embedding Database

144.1k](/packages/codewithkyrian-chromadb-laravel)

PHPackages © 2026

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