Search by

decent-newsroom / nostr-client-bundle

nusapuksic

Reusable Symfony bundle wrapping innis/nostr-client (AMPHP-based async Nostr relay client) for DI-friendly relay connections, subscriptions and publishing

Package info

github.com/decent-newsroom/nostr-client-bundle

Type:symfony-bundle

pkg:composer/decent-newsroom/nostr-client-bundle

Statistics

Installs: 33

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-09-08 12:55 UTC

This package is auto-updated.

Last update: 2026-09-08 12:56:16 UTC


README

A Symfony bundle for innis/nostr-client, an AMPHP-based Nostr relay client. It provides DI-managed client, health-checker, factory, and default connection-config services.

Requirements

  • PHP 8.3 or later
  • Symfony FrameworkBundle 7.4 or later

Installation

composer require decent-newsroom/nostr-client-bundle

Register the bundle if your application does not do so automatically:

// config/bundles.php
return [
    DecentNewsroom\NostrClientBundle\NostrClientBundle::class => ['all' => true],
];

Configuration

# config/packages/nostr_client.yaml
nostr_client:
    connection_timeout_seconds: 10
    auto_reconnect: true
    reconnect_initial_delay_ms: 500
    reconnect_max_delay_ms: 60000
    reconnect_max_attempts: 0
    user_agent: null

Usage

use Innis\Nostr\Client\Application\Port\NostrClientInterface;
use Innis\Nostr\Core\Domain\ValueObject\Protocol\RelayUrl;

final class ExampleService
{
    public function __construct(private readonly NostrClientInterface $client) {}

    public function fetchRecent(string $relayUrl): void
    {
        $relay = RelayUrl::fromString($relayUrl);
        $this->client->connect($relay);
        // ...subscribe/publish as needed; see innis/nostr-client for its API.
        $this->client->close();
    }
}

When connect() receives no ConnectionConfig, the configured default is used. Pass an explicit config to override it for a particular connection:

$client->connect(
    RelayUrl::fromString('wss://relay.example.com'),
    new ConnectionConfig(connectionTimeoutSeconds: 5),
);

Services

  • NostrClientInterface: configured relay client.
  • RelayHealthCheckerInterface: standalone relay health checks.
  • ConnectionConfig: default configuration derived from nostr_client.
  • NostrClientFactoryInterface: factory for raw clients and health checkers.

This bundle wires the client into Symfony. It does not implement Nostr protocol behavior; refer to innis/nostr-client for subscriptions, publishing, and relay lifecycle details.

Changelog

See CHANGELOG.md for release notes.