PHP code example of adlawson / vfs
1. Go to this page and download the library: Download adlawson/vfs 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/ */
adlawson / vfs example snippets
use Vfs\FileSystem;
use Vfs\Node\Directory;
use Vfs\Node\File;
// Create and mount the file system
$fs = FileSystem::factory('vfs://');
$fs->mount();
// Add `/foo` and `/foo/bar.txt`
$foo = new Directory(['bar.txt' => new File('Hello, World!')]);
$fs->get('/')->add('foo', $foo);
// Get contents of `/foo/bar.txt`
$fs->get('/foo/bar.txt')->getContent(); // Hello, World!
file_get_contents('vfs://foo/bar.txt'); // Hello, World!
// Add `/foo/bar` and `/foo/bar/baz.php`
mkdir('vfs://foo/bar');
file_put_contents('vfs://foo/bar.php', ' echo "Hello, World!";');
// Require `/foo/bar.php`