juhara / zzzstream
PSR-7 StreamInterface implementation collection
Installs: 108
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/juhara/zzzstream
This package is not auto-updated.
Last update: 2025-10-31 14:02:41 UTC
README
PSR-7 StreamInterface implementation collection
Requirement
Installation
Run through composer
$ composer require juhara/zzzstream
Available StreamInterface implementation
StringStreamstring-based StreamInterface implementation.ReadOnlyStringStreamread-only string-based StreamInterface implementation.WriteOnlyStringStreamwrite-only string-based StreamInterface implementation.WrapperStreamdecorator class that implements StreamInterface which does nothing except wraps other StreamInterface instance.ReadOnlyStreamdecorator class that turn other StreamInterface into read only stream.WriteOnlyStreamdecorator class that turn other StreamInterface into write only stream.FileStreamfile-based StreamInterface implementation.TempStreamtemporary stream StreamInterface implementation.
How to use
Create stream instance from string
<?php
use Juhara\ZzzStream\StringStream;
...
$stream = new StringStream('hello world');
//replace PSR-7 ResponseInterface instance with new body
$newResponse = $response->withBody($stream);
Create read-only string stream instance
<?php
use Juhara\ZzzStream\ReadOnlyStringStream;
...
$stream = new ReadOnlyStringStream('hello world');
//replace PSR-7 ResponseInterface instance with new body
$newResponse = $response->withBody($stream);
Force string stream instance to become read-only
<?php
use Juhara\ZzzStream\StringStream;
use Juhara\ZzzStream\ReadOnlyStream;
...
$stream = new ReadOnlyStream(new StringStream('hello world'));
//replace PSR-7 ResponseInterface instance with new body
$newResponse = $response->withBody($stream);
Unit Test
To run unit test, copy phpunit.xml.dist to phpunit.xml and run
$ ./vendor/bin/phpunit
Contributing
If you have any improvement or issues please submit PR.
Thank you.