php-standard-library/channel
Message-passing channels for async communication in PHP, inspired by Go and Rust. This package brings typed, concurrent channel primitives to the PHP Standard Library, enabling clean producer/consumer workflows.
The decision this actually informs: whether and where to adopt in-process concurrency primitives in a Laravel codebase.
Swoole\Channel, (b) hand-rolled fiber + queue plumbing, (c) Revolt/Amp primitives directly, or (d) doing nothing and keeping the code sequential. What this package buys is runtime-agnostic channel semantics (buffered/unbuffered, blocking/non-blocking send/receive, iterable consumption, explicit close) on top of the php-standard-library async layer — so you're not pinned to Swoole's API surface. If you're not already on an async runtime, "wait" is the correct answer and this evaluation can be shelved.exit mid-job.Adopt if:
Swoole\Channel, which is a runtime lock-in.ChannelFactory/adapter) so a future swap to Revolt, Swoole, or a rewrite costs days rather than a refactor.Look elsewhere if:
php-standard-library monorepo, so the star count is misleading — but the operational point stands: you are your own support tier.Diligence before committing (half a day, not a sprint):
php-standard-library repo — this package's release notes are one-line pointers, so the split repo tells you nothing about breaking changes.close/error semantics (what does a send to a closed channel do? a receive on empty-but-open?).For executives — frame it as a contained optimization, not a platform play.
"We're evaluating a small library that lets parts of our worker code do several I/O operations at once instead of one after another. It's a targeted fix for specific slow paths, roughly a few days of engineering, MIT-licensed, and fully reversible. It is not a replacement for our queue or message infrastructure, and it doesn't change our architecture."
Be explicit about what it is not, because the attractive-sounding version of this pitch is false. An exec who approves it believing it replaces Redis will judge the team on a promise the technology can't keep. The credible outcome statement is: "reduce tail latency on N identified code paths; no infrastructure change; no new operational surface."
For engineering leadership — lead with blast radius and the honest tradeoffs.
"This gives us Go-style channels for coordination inside a single worker process. It's genuinely useful for worker pools, pipelines, and running independent I/O in parallel.
Three things to be clear about: (1) It's in-process only — zero value for service-to-service communication, so it does not touch our messaging architecture. (2) No persistence — anything in flight is lost on restart, which is fine for coordination and unacceptable for work. (3) The real cost isn't the library, it's the async debugging skill — deadlocks and buffer starvation are hard to diagnose, so this only makes sense where we already run persistent workers.
Recommendation: pilot on one non-critical path — parallel enrichment calls in a single job, or drain-on-shutdown for one worker type — behind our own adapter interface, with a named owner and a rollback plan. Keep it off the critical path until we've operated it for a release cycle."
For developers — show the shape, name the sharp edges.
"Channels are a coordination primitive: producers and consumers on either side of a single in-process boundary, with the buffer size as your backpressure knob. Buffered or unbuffered, blocking or non-blocking send/receive,
foreachto consume, explicitclose.Use it for: parallel independent I/O in one unit of work, bounded worker pools, multi-stage pipelines, clean shutdown of long-running workers. Do not use it for: anything that must survive a restart, anything that leaves the process, anything another language needs to read.
Two rules. Wrap it — nobody imports the library directly; everything goes through our adapter. Instrument it — if you can't see buffer depth and blocked-consumer counts, you can't debug it at 3am."
One line to keep out of every deck: "This lets our microservices talk to each other without HTTP." It doesn't, and shipping a pilot on that premise guarantees a failed evaluation of what is otherwise a reasonable, narrowly-scoped library.
How can I help you explore Laravel packages today?