- How do I install swentel/nostr-php in a Laravel application?
- Install it with Composer using composer require swentel/nostr-php. Because it is a framework-agnostic PHP library rather than a Laravel package, it has no service provider, facade, or config file to publish. You wire it into Laravel yourself, typically through a small service class or container binding that constructs the client with your relay list and key-handling service.
- Is swentel/nostr-php a Laravel package?
- No. swentel/nostr-php is a plain PHP protocol helper library with no service provider, no config publishing, no facade, and no Eloquent integration. That keeps it in the vendor plumbing layer instead of dictating your application architecture. The trade-off is that any Laravel-facing surface, such as configuration, dependency injection, and queued jobs, is yours to build on top of it.
- What can I build with swentel/nostr-php in a Laravel app?
- The library handles the heavy lifting of the Nostr protocol: key handling, event construction and signing, relay message envelopes, filter objects, subscriptions, and helpers for NIPs such as NIP-19 bech32 encoding and NIP-05 identifiers. That makes it suitable for publishing and querying Nostr notes from PHP applications, including bots and client backends. Typical Laravel use cases include dispatching signed events from queued jobs and running a listener process that ingests events into your database.
- Can I publish Nostr events from a Laravel queued job?
- Yes, outbound publishing is a clean fit for Laravel's request-scoped model. You can construct and sign an event, wrap it in an event message, and dispatch it across a relay set inside a queued job, tracking per-relay success. Inbound real-time ingestion is different: Nostr relies on WebSockets and long-lived subscriptions, so it requires a long-running process such as Laravel Octane with Swoole, a supervised Artisan daemon, or a sidecar.
- Which signing backend does swentel/nostr-php use for Schnorr signatures?
- The provided material does not confirm whether the library depends on ext-secp256k1 with the schnorrsig module or includes a pure-PHP fallback. This matters for deployment: a C extension requirement becomes a hard prerequisite for your container base image, CI, and local development, while a pure-PHP fallback makes signature verification throughput the constraint instead. Confirm the backend and measure sign and verify throughput per core before committing.
- Which NIPs does swentel/nostr-php implement?
- The library is described as covering common NIPs, with NIP-19 bech32 encoding and NIP-05 identifier handling specifically called out as worth validating first. Exact coverage for NIP-01 core, NIP-04 and NIP-17 encrypted DMs, NIP-09 deletion, NIP-42 relay auth, and NIP-50 search is not documented in the provided material. Verify the implemented NIPs against your roadmap, and check which ones are tested against a real relay in the repository's suite.
- How should I handle Nostr private keys securely in a Laravel production app?
- The library will sign with a raw private key, so production security is your responsibility. Use envelope encryption at rest plus a KMS, HSM, or Vault-backed signer, define a key rotation policy, and keep an audit trail on every signing operation. A leaked Nostr private key is unrecoverable because there is no issuer to revoke it with.
- Does swentel/nostr-php support multiple concurrent relay connections?
- The provided evaluation does not confirm whether the client supports N relays concurrently or one at a time, and it lists this as a key question for an engineering spike. If the client is single-connection, you will need to shard subscriptions across processes. Plan for relay health management, reconnect and backoff logic, subscription lifecycle, and backpressure yourself, since the library does not provide them.
- How do I test Nostr event publishing in Laravel without hitting real relays?
- Because swentel/nostr-php is a plain library, event construction and signing can be unit tested locally without any network I/O. For relay traffic, wrap the client behind your own interface or adapter and bind a fake implementation in Laravel's container during tests. This keeps your test suite fast and avoids depending on third-party relay availability, which the library does not abstract away for you.
- Is swentel/nostr-php actively maintained and safe to depend on?
- The project has roughly 70 stars and appears to be a single-maintainer dependency, with a release dated 2026-02-03 suggesting active maintenance. There is no semver-backed support window or changelog SLA, and Nostr NIPs evolve informally, so pin the version and read diffs before upgrading. The MIT license and small surface area make fork-and-own realistic; also check that no transitive dependency is unmaintained, since older PHP Nostr libraries relied on the effectively abandoned simplito/elliptic-php.