Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Psl Laravel Package

azjezz/psl

PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.

View on GitHub
Deep Wiki
Context7

Channel

The Channel component provides message-passing channels for async communication, inspired by Go's channels and Rust's std::sync::mpsc. A channel splits into a SenderInterface and a ReceiverInterface, giving you a clear separation between the producing and consuming sides.

Channels come in two flavors:

  • Bounded -- Has a fixed capacity. Sending blocks when the channel is full.
  • Unbounded -- Grows without limit. Sending never blocks due to capacity.

Usage

Creating Channels

Both factory functions return a [ReceiverInterface, SenderInterface] pair:

@example('async/channel-basic.php')

Sending and Receiving

@example('async/channel-send-receive.php')

send() waits for space if the channel is full. receive() waits for a message if the channel is empty. For non-blocking alternatives, use trySend() and tryReceive(), which throw immediately instead of waiting:

@example('async/channel-try-send-receive.php')

Closing Channels

Closing a channel signals that no more messages will be sent. Messages already in the channel can still be received:

@example('async/channel-closing.php')

Inspecting Channel State

@example('async/channel-inspecting.php')

For unbounded channels, getCapacity() returns null and isFull() always returns false.

Producer-Consumer Pattern

@example('async/channel-producer-consumer.php')

Fan-Out: Multiple Consumers

Distribute work across several consumers by sharing the receiver:

@example('async/channel-fan-out.php')

Cancellation

Both send() and receive() accept an optional CancellationTokenInterface. This is useful when you don't want to wait indefinitely for a message or for space in a bounded channel:

@example('async/channel-cancellation.php')

trySend() and tryReceive() are non-blocking and don't need cancellation tokens -- they throw immediately if the channel is full or empty.

When to Use Channel

  • Decoupling producers and consumers -- The sender doesn't need to know who processes the messages
  • Backpressure -- Bounded channels naturally slow down fast producers when consumers can't keep up
  • Async coordination -- Pass data between concurrent tasks without shared mutable state

See src/Psl/Channel/ for the full API.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4