1. Go to this page and download the library: Download muninndb/client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muninndb / client example snippets
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;
// In your plugin file
ent;
$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);
// 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);
}
// 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}";