An adapter for the Flysystem file system abstraction library which creates a temporary directory on local filesystem and which is automatically removed again on object destruct.
composer require emgag/flysystem-tempdir
As League\Flysystem\Filesystem wrapper:
use Emgag\Flysystem\Tempdir;
$fs = new Tempdir($prefix = '', $tempdir = null, $destruct = true);
// fully qualified FS path
$fsPath = $fs->getPath();
or as Flysystem Adapter:
use Emgag\Flysystem\TempdirAdapter;
use League\Flysystem\Filesystem;
$adapter = new TempdirAdapter($prefix = '', $tempdir = null, $destruct = true);
$filesystem = new Filesystem($adapter);
// fully qualified FS path
$fsPath = $adapter->getPath();
flysystem-tempdir is licensed under the MIT License.