decodelabs / deliverance
Shared data transfer interfaces
Installs: 17 625
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/exceptional: ^0.4
- decodelabs/tightrope: ^0.1.1
Requires (Dev)
README
Shared data transfer interfaces for PHP
Deliverance is a middleware library intended to be used by other framework systems that need to manage multiplex IO operations.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/deliverance
Usage
Channels
Channels represent simple in / out handlers and can be written to and read from:
use DecodeLabs\Deliverance; $stream = Deliverance::openStream('path/to/file'); $stream->writeLine('Hello world'); $stream = Deliverance::openCliOutputStream(); // Same as new Deliverance\Channel\Stream(STDOUT); $buffer = Deliverance::newBuffer(); $buffer->write('Some text to buffer'); echo $buffer->read(6); // "Some t"
IO Broker
Channels can be grouped together and managed by an IO Broker
-
use DecodeLabs\Deliverance; // Create a CLI IO handler $broker = Deliverance::newBroker() ->addInputProvider(Deliverance::openStream(STDIN)) ->addOutputReceiver(Deliverance::openStream(STDOUT)) ->addErrorReceiver(Deliverance::openStream(STDERR)); // Shortcut to the above: $broker = Deliverance::newCliBroker(); // Read line from CLI $broker->setReadBlocking(true); $text = $broker->readLine(); // Write it back to output $broker->writeLine('INPUT: '.$text);
Once grouped, the Channels in an IO broker can be used as the interface between many different information sources; see Systemic Unix process launcher for an example of an IO Broker managing input and output with proc_open()
.
Licensing
Deliverance is licensed under the MIT License. See LICENSE for the full license text.