Flysystem memory adapter

Author Build Status Coverage Status Software License Packagist Version

This adapter keeps a filesystem in memory. It should be useful for tests, allowing you to have a working filesystem without having to clean up after each test run.

Installation

composer require twistor/flysystem-memory-adapter

Usage

use League\Flysystem\Filesystem;
use Twistor\Flysystem\MemoryAdapter;

$filesystem = new Filesystem(new MemoryAdapter());

$filesystem->write('new_file.txt', 'yay a new text file!');

$contents = $filesystem->read('new_file.txt');

// If you have existing test files, you can populate the memory adapter from a
// filesystem path.
$adapter = MemoryAdapter::createFromPath('path/to/some/folder');

// Or, you can use an existing filesystem, and convert it.
$adapter = MemoryAdapter::createFromFilesystem($filesystem);