33 lines
1.6 KiB
Markdown
33 lines
1.6 KiB
Markdown
|
# Flysystem Memory Adapter
|
||
|
|
||
|
[](https://twitter.com/chrisleppanen)
|
||
|
[](https://travis-ci.org/thephpleague/flysystem-memory)
|
||
|
[](https://scrutinizer-ci.com/g/thephpleague/flysystem-memory/code-structure)
|
||
|
[](https://scrutinizer-ci.com/g/thephpleague/flysystem-memory)
|
||
|
[](LICENSE)
|
||
|
[](https://packagist.org/packages/league/flysystem-memory)
|
||
|
[](https://packagist.org/packages/league/flysystem-memory)
|
||
|
|
||
|
This adapter keeps the filesystem in memory. It's useful when you need a filesystem, but do not need it persisted.
|
||
|
|
||
|
## Installation
|
||
|
|
||
|
```bash
|
||
|
composer require league/flysystem-memory
|
||
|
```
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
```php
|
||
|
use League\Flysystem\Filesystem;
|
||
|
use League\Flysystem\Memory\MemoryAdapter;
|
||
|
|
||
|
$filesystem = new Filesystem(new MemoryAdapter());
|
||
|
|
||
|
$filesystem->write('new_file.txt', 'yay a new text file!');
|
||
|
|
||
|
$contents = $filesystem->read('new_file.txt');
|
||
|
|
||
|
// Explicitly set timestamp (e.g. for testing)
|
||
|
$filesystem->write('old_file.txt', 'very old content', ['timestamp' => 13377331]);
|
||
|
```
|