Creates a filesystem from a sub-folder in another filesystem.

1.0.1 2019-09-24 14:58 UTC

This package is auto-updated.

Last update: 2020-07-06 21:57:06 UTC


Author Latest Stable Version Build Status Coverage Status Scrutinizer Code Quality StyleCI Software License

This adapter creates a new filesystem from a sub-folder of an existing filesystem.


composer require fisharebest/flysystem-chroot-adapter


use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use Fisharebest\Flysystem\Adapter\ChrootAdapter

// Write a file to a filesystem.
$filesystem = new Filesystem(new Local(__DIR__));
$filesystem->write('foo/bar/fab/file.txt', 'hello world!');

// Create a chroot filesystem from the foo/bar folder.
$chroot = new Filesystem(new ChrootAdapter($filesystem, 'foo/bar'));

// And read it back from the chroot.
$chroot->read('fab/file.txt'); // 'hello world!'