PHPackages                             brianhenryie/bh-php-flysystem-readonly - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. brianhenryie/bh-php-flysystem-readonly

ActiveLibrary[File &amp; Storage](/categories/file-storage)

brianhenryie/bh-php-flysystem-readonly
======================================

A League Flysystem adapter which wraps another adapter: reads pass through, writes and deletes are captured in memory so nothing ever touches the underlying filesystem. For --dry-run modes.

1.0.0(today)014↑2900%MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 27Pushed todayCompare

[ Source](https://github.com/BrianHenryIE/bh-php-flysystem-readonly)[ Packagist](https://packagist.org/packages/brianhenryie/bh-php-flysystem-readonly)[ RSS](/packages/brianhenryie-bh-php-flysystem-readonly/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

[![Flysystem 2 | 3](https://camo.githubusercontent.com/e82bb0ccb8922a1de127f77d8634e64c9d370fe17a4da3ad5b5b970a1f0d5781/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f466c7973797374656d2d32253230253743253230332d626c75652e737667)](https://flysystem.thephpleague.com/)![PHP 7.4 | 8.x](https://camo.githubusercontent.com/4ac67fcea0ec57ed2f2332e01b527aa4fe699badd80e967ef5679ba35fc6a555/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e34253230253743253230382e782d3838393242462e737667)[![Code Coverage](.github/coverage.svg)](https://brianhenryie.github.io/bh-php-flysystem-readonly/)[![PHPCS PEAR](https://camo.githubusercontent.com/3a0b87013042241c5d7f02d3b6b096e0d61d7f21ebffe96ce8990f5af364cd0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50485043532d5045415225374350535225323031322532302d3465396130362e737667)](https://pear.php.net/manual/en/standards.php)[![PHPStan ](.github/phpstan.svg)](https://phpstan.org/)

Flysystem Read-Only Adapter
===========================

[](#flysystem-read-only-adapter)

A [League Flysystem](https://flysystem.thephpleague.com/) adapter which wraps another adapter: reads pass through to it, writes and deletes are captured in memory. The underlying filesystem is never modified, but code running on top of it sees its own changes as though they had been written. Uses [league/flysystem-memory](https://flysystem.thephpleague.com/docs/adapter/in-memory/) to store changes.

Created to use for `--dry-run` mode needs: the whole program runs normally – writing files, deleting them, listing directories, reading back what it just wrote – and nothing reaches the disk. This was extracted from [Strauss](https://github.com/BrianHenryIE/strauss), where it implements `strauss --dry-run`.

Install
-------

[](#install)

```
composer require brianhenryie/bh-php-flysystem-readonly
```

Use
---

[](#use)

```
use BrianHenryIE\FlysystemReadOnly\ReadOnlyFileSystemAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$adapter = new LocalFilesystemAdapter('/path/to/project');

if ($isDryRun) {
    $adapter = new ReadOnlyFileSystemAdapter($adapter);
}

$filesystem = new Filesystem($adapter);

$filesystem->write('src/Example.php', '
