-
Notifications
You must be signed in to change notification settings - Fork 1
PSR 17: StreamFactory Example
Terry L edited this page Jun 21, 2020
·
3 revisions
Namespace
Shieldon\Psr17\StreamFactoryNone
-
param
stringcontent= ""String content with which to populate the stream. -
return
StreamInterface
Example:
$streamFactory = new StreamFactory();
$stream = $streamFactory->createStream('Foo Bar');
echo $stream;
// Outputs: Foo Bar-
param
stringfilename*The filename or stream URI to use as basis of stream. -
param
stringmoderThe mode with which to open the underlying filename/stream. -
return
StreamInterface
Example:
$sourceFile = BOOTSTRAP_DIR . '/sample/shieldon_logo.png';
$streamFactory = new StreamFactory();
$stream = $streamFactory->createStreamFromFile($sourceFile);
echo $stream->getSize();
// Outputs: 15166-
param
stringresource*The PHP resource to use as the basis for the stream. -
return
StreamInterface
Example:
$streamFactory = new StreamFactory();
$stream = $streamFactory->createStreamResource(
fopen('php://temp', 'r+')
);composer require shieldon/psr-httpShieldon PSR HTTP implementation written by Terry L. from Taiwan.
