-
Notifications
You must be signed in to change notification settings - Fork 2
StreamFactory: createStreamFromFile Example
Terry L edited this page Jun 21, 2020
·
4 revisions
Shieldon\Psr17\StreamFactory
Create a stream from an existing file.
$mode may be any mode supported by the fopen
function.
-
param
string
filename*
The filename or stream URI to use as basis of stream. -
param
string
moder
The 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
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.