Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vfsstream: file_get_contents() failed to open stream: stream_open call failed

I have set up a vfsstream block device and I'm trying to call file_get_contents() on it. However the call to vfsStreamWrapper::stream_open fails and therefore the stream cannot be opened.

Here is my code:

$this->root = vfsStream::setup('root');
$this->root->addChild(new vfsStreamBlock('test_block_device'));
$this->root->addChild(new vfsStreamFile('not_block_device'));
echo file_get_contents('vfs://root/test_block_device/size');

Here is the error:

file_get_contents(vfs://root/test_block_device/size): failed to open stream: "org\bovigo\vfs\vfsStreamWrapper::stream_open" call failed

Here is the closest issue I've found on this

However his was an issue with phpunit's teardown and mine happens mid-test.

like image 923
Conor Wright Avatar asked Jan 20 '26 14:01

Conor Wright


1 Answers

From the docs it seems that you need to add some content to your block device before you read from it: https://github.com/mikey179/vfsStream/wiki/BlockDevices

like image 75
frak Avatar answered Jan 22 '26 02:01

frak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!