A stream wrapper for Flysystem V2 & V3.

v1.3.1 2022-08-12 13:48 UTC

This package is auto-updated.

Last update: 2022-09-12 14:14:17 UTC


Author Software License

This package provides a stream wrapper for Flysystem V2 & V3.

Flysystem V1

If you're looking for Flysystem 1.x support, check out the twistor/flysystem-stream-wrapper.


composer require m2mtech/flysystem-stream-wrapper


use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use M2MTech\FlysystemStreamWrapper\FlysystemStreamWrapper;

$filesystem = new Filesystem(new LocalFilesystemAdapter('/some/path'));
FlysystemStreamWrapper::register('fly', $filesystem);

file_put_contents('fly://filename.txt', $content);


Because locking is not supported by Flysystem V2, the stream wrapper implements symfony/lock. As default, it uses file locking using /tmp, which you can adjust via the configuration:

FlysystemStreamWrapper::register('fly', $filesystem, [
    FlysystemStreamWrapper::LOCK_STORE => 'flock:///tmp',
    FlysystemStreamWrapper::LOCK_TTL => 300,

Problems with Visibility

Some adaptors seem to throw an exception when visibility is used. To be able to use such adaptors, tell the stream wrapper to ignore them, e.g.:

FlysystemStreamWrapper::register('fly', $filesystem, [
    FlysystemStreamWrapper::IGNORE_VISIBILITY_ERRORS => true,

Problems with is_readable / is_writable

A couple of filesystem functions use uid and gid of the user running php. Unfortunately there is no straight forward cross-plattform usable method available to derive those values. The wrapper tries to guess them. But depending on your system settings it might fail. In such cases you can set them manually, e.g.:

FlysystemStreamWrapper::register('fly', $filesystem, [
    FlysystemStreamWrapper::UID => 1000,
    FlysystemStreamWrapper::GID => 1000,

or go haywire accessing the parameters for PortableVisibilityConverter directly via:

FlysystemStreamWrapper::register('fly', $filesystem, [
    FlysystemStreamWrapper::VISIBILITY_FILE_PUBLIC => 0644,
    FlysystemStreamWrapper::VISIBILITY_FILE_PRIVATE => 0600,
    FlysystemStreamWrapper::VISIBILITY_DIRECTORY_PUBLIC => 0755,
    FlysystemStreamWrapper::VISIBILITY_DIRECTORY_PRIVATE => 0700,
    FlysystemStreamWrapper::VISIBILITY_DEFAULT_FOR_DIRECTORIES => Visibility::PRIVATE,


This package has been developed for php 7.4 with compatibility tested for php 7.2 to 8.1.

# with php installed
composer test

# or inside docker e.g. for php 7.4
docker-compose run php74 composer test


Please see CHANGELOG for more information about recent changes.


Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.



The MIT License (MIT). Please see License File for more information.