1. Go to this page and download the library: Download christeredvartsen/testfs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
christeredvartsen / testfs example snippets
use TestFs\StreamWrapper;
StreamWrapper::register();
function TestFs\url;
echo url('path/to/file.php'); // tfs://path/to/file.php
TestFs\StreamWrapper;
use function TestFs\file_get_contents;
use function TestFs\file_put_contents;
use function TestFs\mkdir;
StreamWrapper::register();
mkdir('foo/bar', 0777, true);
file_put_contents('foo/bar/baz.txt', 'Hello World!');
echo file_get_contents('foo/bar/baz.txt'); // Hello World!