PHP code example of decodelabs / deliverance

1. Go to this page and download the library: Download decodelabs/deliverance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

decodelabs / deliverance example snippets


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"

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);