1. Go to this page and download the library: Download nexo/plugin-sdk 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/ */
nexo / plugin-sdk example snippets
use Nexo\Plugin\Sdk\PluginAdapter; // async dispatch loop
use Nexo\Plugin\Sdk\BrokerSender; // write-only broker handle
use Nexo\Plugin\Sdk\Event; // value object
use Nexo\Plugin\Sdk\Manifest; // standalone TOML parser
use Nexo\Plugin\Sdk\StdoutGuard; // defensive guard installable independently
use Nexo\Plugin\Sdk\Wire; // JSON-RPC frame helpers + MAX_FRAME_BYTES
use Nexo\Plugin\Sdk\PluginError; // base exception
use Nexo\Plugin\Sdk\ManifestError; // raised when nexo-plugin.toml is malformed
use Nexo\Plugin\Sdk\WireError; // raised on malformed JSON-RPC or oversized frames
declare(strict_types=1);
der;
use Nexo\Plugin\Sdk\Event;
use Nexo\Plugin\Sdk\PluginAdapter;
$adapter = new PluginAdapter([
'manifestToml' => file_get_contents(__DIR__ . '/../../nexo-plugin.toml'),
'onEvent' => function (string $topic, Event $event, BrokerSender $broker): void {
$out = Event::new(
'plugin.inbound.my_kind',
'my_plugin',
['echoed' => $event->payload],
);
$broker->publish('plugin.inbound.my_kind', $out);
},
]);
$adapter->run();
'onEvent' => function (string $topic, Event $event, BrokerSender $broker): void {
$entries = $broker->memoryRecall(['agentId' => 'my_agent', 'query' => 'user prefers concise answers', 'limit' => 5]);
// $entries: MemoryEntry[] (id, agentId, content, tags, conceptTags, createdAt, memoryType)
$r = $broker->llmComplete([
'provider' => 'minimax', 'model' => 'minimax-m2.5',
'messages' => [['role' => 'user', 'content' => 'summarize: ...']],
'systemPrompt' => 'You answer concisely.',
]);
// $r->content, $r->finishReason, $r->usage->{promptTokens, completionTokens}
$final = $broker->llmCompleteStream(
['provider' => 'minimax', 'model' => 'minimax-m2.5', 'messages' => [['role' => 'user', 'content' => '...']]],
function (string $chunk): void { /* called once per chunk, in order */ },
);
// $final is the LlmCompleteResult; $final->content is null (the chunks were the content)
},
bash
cd php
composer install
php tests/run-all.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.