decent-newsroom / nostr-client-bundle
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
Requires
- php: ^8.3
- innis/nostr-client: ^0.1.7
- innis/nostr-core: ^0.3.17
- psr/log: ^3.0
- symfony/framework-bundle: ^7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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 fromnostr_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.