首页 > 解决方案 > fopen() 使用 Vfs 失败,'无法打开流:“org\bovigo\vfs\vfsStreamWrapper::stream_open”'

问题描述

使用 vfsStream,我正在向 vfs 写入一个文件,我可以读取它的内容:

$vfsRoot = \org\bovigo\vfs\vfsStream::setup('root');
$vfsRoot->addChild(\org\bovigo\vfs\vfsStream::newDirectory('mydir'));
$directory = \org\bovigo\vfs\vfsStream::url('root/mydir');

file_put_contents("vfs://root/mydir/test.txt", 'test!!');

$contents = file_get_contents("vfs://root/mydir/test.txt");

一切正常——如果我 dump($contents) 我看到了我的期望。

但是,这样做会导致警告:

$fp = fopen("vfs://root/mydir/test.txt", "rw+");

警告:fopen(vfs://root/mydir/test.txt):无法打开流:“org\bovigo\vfs\vfsStreamWrapper::stream_open”调用失败

我究竟做错了什么?

标签: phpvfs-stream

解决方案


推荐阅读