https://github.com/decodelabs/deliverance
Shared data transfer interfaces for PHP
https://github.com/decodelabs/deliverance
data-transfer input-output multiplex php
Last synced: about 1 year ago
JSON representation
Shared data transfer interfaces for PHP
- Host: GitHub
- URL: https://github.com/decodelabs/deliverance
- Owner: decodelabs
- License: mit
- Created: 2021-04-09T13:08:13.000Z (about 5 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-14T08:44:33.000Z (about 1 year ago)
- Last Synced: 2025-04-14T09:44:59.781Z (about 1 year ago)
- Topics: data-transfer, input-output, multiplex, php
- Language: PHP
- Homepage:
- Size: 102 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Deliverance
[](https://packagist.org/packages/decodelabs/deliverance)
[](https://packagist.org/packages/decodelabs/deliverance)
[](https://packagist.org/packages/decodelabs/deliverance)
[](https://github.com/decodelabs/deliverance/actions/workflows/integrate.yml)
[](https://github.com/phpstan/phpstan)
[](https://packagist.org/packages/decodelabs/deliverance)
### 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.
---
## Installation
Install via Composer:
```bash
composer require decodelabs/deliverance
```
## Usage
### Channels
Channels represent simple in / out handlers and can be written to and read from:
```php
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 -
```php
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](https://github.com/decodelabs/systemic/blob/develop/src/Systemic/Process/Launcher/Unix.php) for an example of an IO Broker managing input and output with proc_open().
## Licensing
Deliverance is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.