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.
Architecture fit: basis-company/nats is a framework-agnostic PHP NATS/JetStream client, not a Laravel package. It fits Laravel services when NATS is already the strategic messaging backbone or when JetStream persistence, request/reply, KV, and service endpoints are genuinely needed. It does not provide a Laravel queue driver, service provider, config publishing, Horizon-style observability, or Laravel-native worker integration. Best fit is event-driven bounded contexts, asynchronous fan-out, durable consumers, and cross-service request/reply. Poor fit is a team expecting a drop-in Redis/SQS/RabbitMQ replacement.
Integration feasibility: Composer installation is straightforward, but production integration requires internal Laravel glue: configuration wrapper, singleton client lifecycle, health check, worker commands, and optional service provider. NKeys/JWT support depends on libsodium or sodium_compat. TLS and JWT features are present. The client is blocking and uses process()/handle() loops, so it should run in dedicated workers, not in HTTP request paths. A small pilot is feasible; broad adoption is not turnkey.
Technical risk: Ecosystem signal is weak: 212 stars, 0 dependents, score 36.76, opportunity 48.27. There is no Laravel ecosystem backing and likely limited community bug pressure. The stated last release date of 2026-10-14 is future-dated relative to normal release cadence and should be verified for provenance. Support is community-only. Risks include API churn, missing Laravel queue contract, operational complexity of NATS/JetStream, duplicate delivery and ack semantics, and reliance on a small maintainer base. The README performance claims are client-level benchmarks, not evidence for Laravel workload performance.
Key questions: Is NATS already a strategic platform, or would this add a new broker? What problem cannot Redis/SQS/RabbitMQ solve? Who operates NATS, JetStream storage, TLS, and credential rotation? What delivery semantics and idempotency guarantees are required? Which PHP and Laravel versions must be supported? Is Octane or long-lived worker usage planned? What SLOs, support expectations, and exit ramps are required? Can we pin, wrap, or fork the package if upstream stalls?
Stack fit: The package can sit inside a Laravel/PHP stack as a Composer dependency, but it should be hidden behind an internal integration layer: config/nats.php, a service provider, a managed singleton client, health checks, and dedicated worker commands. Domain code should not depend directly on client classes. Use Laravel logging, events, metrics, and deployment tooling around the client. For Octane or long-running workers, explicitly manage reconnect and connection lifecycle.
Migration path: Do not replace an existing Laravel queue in one step. Start with a non-critical async flow or a side-channel event stream. Run NATS in parallel with the current queue and compare delivery, lag, duplicates, and operational burden. Promote one bounded context at a time. Keep an exit ramp to the existing queue until reliability is proven. For existing jobs, wrap handlers behind an internal interface and migrate job-by-job.
Compatibility: Pin the NATS server version, JetStream configuration, and client package version. Validate TLS certificates, JWT/NKey credentials, libsodium availability, PHP version constraints, and Laravel worker lifecycle behavior. Laravel version compatibility is mostly indirect because the package is framework-agnostic. Test with Docker locally, a staging cluster with production-like TLS, and deployment restarts. Confirm semantic versioning and supported PHP versions before committing.
Sequencing: 1) Decide whether NATS is strategically justified and assign infrastructure ownership. 2) Run a proof of concept with one stream, one consumer, idempotency, retry, and dead-letter behavior. 3) Build the internal Laravel wrapper and observability. 4) Pilot one bounded context with explicit SLOs. 5) Harden reconnect, ack/nack, poison-message handling, credential rotation, and failure alerting. 6) Expand only after pilot review. 7) Reassess cost, support burden, and benefit versus the existing queue.
Maintenance: Pin the exact package version and monitor upstream releases and commits. Budget an internal owner because low dependents means fewer community fixes and less battle-testing. Verify the anomalous future-dated release metadata. Be prepared to wrap or fork the client for critical fixes, especially if it enters a production-critical path.
Support: Expect community-only support with no commercial SLA. Internal on-call must own NATS cluster health, JetStream storage, client behavior, TLS expiry, and credential rotation. Create runbooks for broker outage, consumer lag, redeliveries, and poison messages. Escalation to upstream maintainers is not guaranteed.
Scaling: NATS/JetStream can scale well, but the PHP worker model and blocking client define application scaling. Scale consumers horizontally with durable consumers or queue groups; tune batching, iterations, and timeouts; monitor consumer lag, ack pending, redeliveries, and stream storage. Benchmark with a Laravel-like workload rather than relying only on README throughput claims. Plan JetStream storage, replication, and retention capacity.
Failure modes: Broker unavailability, reconnect delay loops, duplicate delivery, poison messages, incorrect ack/nack behavior, lost ephemeral consumers, consumer lag, memory growth in long-running workers, TLS/JWT expiry, silent publish failures, and lack of a native dead-letter queue. Mitigations include idempotency keys, explicit retry policy, dead-letter handling, alerting, and chaos testing.
Ramp-up: The team needs NATS/JetStream training beyond normal Laravel queue experience. Start with one team and one pilot, then create examples, dashboards, runbooks, and a code review checklist. Expect roughly two to four weeks for a competent Laravel team to reach pilot confidence, with additional time for production hardening. Expansion should be gated on SLOs, error budget, and operational readiness.
How can I help you explore Laravel packages today?