Write data directly to the process stdout. This is useful for streaming data to web clients without buffering in memory.
Note: Stdout is write-only-reading is not supported.
Write data directly to the process stdout. This is useful for streaming data to web clients without buffering in memory.
Note: Stdout is write-only-reading is not supported.
Every reader and writer reaches storage through the filesystem abstraction.
<?php
declare(strict_types=1);
use function Flow\Filesystem\DSL\{fstab, path};
require __DIR__ . '/vendor/autoload.php';
$filesystem = fstab()->for('file');
foreach (['first.txt' => "one\n", 'second.txt' => "two\n"] as $name => $content) {
$stream = $filesystem->writeTo(path(__DIR__ . '/listing/' . $name));
$stream->append($content);
$stream->close();
}
$outputStream = fstab()->for('stdout')->writeTo(path('stdout://'));
$outputStream->append("Files List\n\n");
foreach ($filesystem->list(path(__DIR__ . '/listing/*.txt')) as $file) {
$outputStream->append(($file->isFile() ? 'File' : 'Directory') . ': ' . $file->path->basename() . "\n");
}
$outputStream->close();