PHP code example of christeredvartsen / testfs

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();



use TestFs\StreamWrapper;

StreamWrapper::register();

$device = StreamWrapper::getDevice();
$device->buildFromDirectory('./src');

echo $device->tree() . PHP_EOL;


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!

/
├── Asset.php
├── Device.php
├── Directory.php
├── Exception
│   ├── DuplicateAssetException.php
│   ├── DuplicateGroupException.php
│   ├── DuplicateUserException.php
│   ├── InsufficientStorageException.php
│   ├── InvalidAssetNameException.php
│   ├── InvalidFopenModeException.php
│   ├── InvalidUrlException.php
│   ├── InvalidWhenceException.php
│   ├── ProtocolAlreadyRegisteredException.php
│   ├── RuntimeException.php
│   ├── UnknownAssetException.php
│   ├── UnknownGroupException.php
│   └── UnknownUserException.php
├── File.php
├── FopenMode.php
├── RootDirectory.php
├── StreamWrapper.php
└── functions.php

1 directory, 21 files