PHP code example of decent-newsroom / nostr-client-bundle
1. Go to this page and download the library: Download decent-newsroom/nostr-client-bundle 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/ */
decent-newsroom / nostr-client-bundle example snippets
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();
}
}
$client->connect(
RelayUrl::fromString('wss://relay.example.com'),
new ConnectionConfig(connectionTimeoutSeconds: 5),
);