本文整理匯總了PHP中Psr7Middlewares\Middleware::getStreamFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Middleware::getStreamFactory方法的具體用法?PHP Middleware::getStreamFactory怎麽用?PHP Middleware::getStreamFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr7Middlewares\Middleware
的用法示例。
在下文中一共展示了Middleware::getStreamFactory方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createStream
/**
* Get the stream factory.
*
* @param string|StreamInterface $file Filename or stream it's replacing
* @param string $mode
*
* @return StreamInterface
*/
private static function createStream($file = 'php://temp', $mode = 'r+')
{
$factory = Middleware::getStreamFactory();
$replacing = null;
if ($file instanceof StreamInterface) {
$replacing = $file;
$file = 'php://temp';
}
if ($factory === null) {
if (class_exists('Zend\\Diactoros\\Stream')) {
return new \Zend\Diactoros\Stream($file, $mode);
}
throw new \RuntimeException('Unable to create a stream. No stream factory defined');
}
return call_user_func($factory, $file, $mode, $replacing);
}