basis-company/nats
A PHP client for NATS with publish/subscribe, request/response, JetStream, microservices, and key-value storage. Supports TLS and JWT authentication plus configurable retry delays.
service() endpoint APIs give PHP teams a first-class way to expose Laravel domain logic as subject-addressable endpoints (v1.posts.*) without standing up HTTP gateways between internal services.WORK_QUEUE retention plus ack()/nack(timeout) and batching (setBatching, setIterations, fetchAll) map directly onto work-queue semantics — a credible alternative to Redis/SQS for durable at-least-once delivery, particularly if NATS is already in the infra footprint.put/update with revision guards, getAll, purge) covers feature flags, config distribution, and lightweight distributed locks — features that otherwise become a separate service or a schema on top of Redis.Adopt when:
tlsCaFile/tlsCertFile/tlsKeyFile, and CredentialsParser::fromFile() are all documented, which is a meaningful signal for production use.libsodium (or accepts sodium_compat), and can own a thin Laravel wrapper internally.Look elsewhere when:
dispatch()/ShouldQueue — evaluate dedicated queue-driver packages or stay on Redis/SQS.dispatch() will burn a worker; this fits long-running CLI workers, not web requests.To executives: This is a low-cost, zero-license-fee way to make our Laravel services first-class participants in an event-driven architecture alongside our other language runtimes. It ships everything we'd otherwise build ourselves — connection resilience, TLS/mTLS, JWT auth, durable JetStream consumers with retry semantics, a key-value store for feature flags and config, and a microservice endpoint layer — under an MIT license with no vendor lock-in. The trade-off is ecosystem maturity: negligible third-party adoption and a single maintainer, so we treat it as a forkable dependency we pin and wrap, not a strategic vendor. Recommended decision: adopt behind an internal abstraction for one bounded use case (durable work queue or internal service endpoint), with a two-week integration spike and a security/dependency review.
To engineering: You get a protocol implementation you don't have to write, with exponential-backoff reconnects, TLS and NKey/JWT credentials, request/reply (request/dispatch), JetStream streams and consumers (durable and ephemeral), ack/nack with timeout, batching over fetchAll, and KV with revision-guarded updates. Costs: you own the Laravel glue (service provider, config, worker lifecycle, observability), you pin the version and review upgrades manually given low downstream usage, and you validate JetStream feature coverage against our roadmap before we design around it. Non-negotiable: run consumers as long-lived CLI workers, make handlers idempotent, and never block inside a web request.
How can I help you explore Laravel packages today?