# Class HttpSoft\Message\StreamFactory
Factory for creating HttpSoft\Message\Stream, implements Psr\Http\Message\StreamFactoryInterface.
use HttpSoft\Message\StreamFactory;
$factory = new StreamFactory();
// Create `HttpSoft\Message\Stream` instance from an existing file.
$stream = $factory->createStreamFromFile('path/to/file', 'r');
$stream->getMetadata('uri'); // 'path/to/file'
$stream->getContents(); // 'File content'
// Create `HttpSoft\Message\Stream` instance from an existing resource.
$resource = fopen('path/to/file', 'r');
$stream = $factory->createStreamFromResource($resource);
$stream->getMetadata('uri'); // 'path/to/file'
$stream->getContents(); // 'File content'
// Create `HttpSoft\Message\Stream` instance from a string usage a temporary resource.
$stream = $factory->createStream('Content');
$stream->getMetadata('uri'); // 'php://temp'
$stream->getContents(); // 'Content'
# Public methods
See the original detailed description of the methods in the Psr\Http\Message\StreamFactoryInterface.
# createStream
Create a new HttpSoft\Message\Stream instance from a string usage a temporary resource.
public function createStream(string $content = ''): StreamInterface;
# createStreamFromFile
Create a new HttpSoft\Message\Stream instance from an existing file.
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface;
# createStreamFromResource
Create a new HttpSoft\Message\Stream instance from an existing resource.
/**
* @param resource $resource
* @return StreamInterface
*/
public function createStreamFromResource($resource): StreamInterface;