PHPackages                             pollen-solutions/filesystem - 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. pollen-solutions/filesystem

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

pollen-solutions/filesystem
===========================

Pollen Solutions - Filesystem Component - Abstraction layer of file storage library Flysystem.

v1.0.1(4y ago)07MITPHPPHP ^7.4 || ^8.0

Since Aug 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/pollen-solutions/filesystem)[ Packagist](https://packagist.org/packages/pollen-solutions/filesystem)[ Docs](https://www.presstify.com/pollen-solutions/filesystem/)[ RSS](/packages/pollen-solutions-filesystem/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Filesystem Component
====================

[](#filesystem-component)

[![Latest Stable Version](https://camo.githubusercontent.com/6d840c8db99ea2928d322c792ef42e342ba46f22d60b61c52193318e771cbae9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c6c656e2d736f6c7574696f6e732f66696c6573797374656d2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/pollen-solutions/filesystem)[![MIT Licensed](https://camo.githubusercontent.com/daa52099573be5a50c320c4387496400f2f722e49f86a42db8d5778130d3582d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE.md)[![PHP Supported Versions](https://camo.githubusercontent.com/d9d71d0b69072c51e1ff7adfdb6270f896f75787500ce6437120e23727c081d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d3838393242463f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/supported-versions.php)

Pollen Solutions **Filesystem** Component is an abstraction layer of file storage library [Flysystem](https://flysystem.thephpleague.com/v2/docs/).

Installation
------------

[](#installation)

```
composer require pollen-solutions/filesystem
```

Basic Usage
-----------

[](#basic-usage)

```
use Pollen\Filesystem\StorageManager;

$storage = new StorageManager();

try {
    $listing = $storage->listContents('/');

    /** @var \League\Flysystem\StorageAttributes $item */
    foreach ($listing as $item) {
        $path = $item->path();

        if ($item instanceof \League\Flysystem\FileAttributes) {
            var_dump($path);
        } elseif ($item instanceof \League\Flysystem\DirectoryAttributes) {
            var_dump($path);
        }
    }
} catch (\League\Flysystem\FilesystemException $e) {
    var_dump($e->getMessage());
}
```

API
---

[](#api)

The API of the pollen solutions filesystem is identical to that of Flysystem which it inherits. More information on [Flysystem online official documentation](https://flysystem.thephpleague.com/v2/docs/usage/filesystem-api/).

Storage Manager inherits the Filesystem instance's methods from its default disk and provides other methods to access other declared disk instances.

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */

// Gets a filesystem instance provided by the storage manager from its name identifier.
$storage->disk('my-own-disk');

// Writing files in default filesystem.
try {
    $storage->write($path, $contents, $config);
} catch (\League\Flysystem\FilesystemException | \League\Flysystem\UnableToWriteFile $exception) {
    // handle the error
}

// Reading files in default filesystem.
try {
    $response = $storage->read($path);
} catch (FilesystemException | UnableToReadFile $exception) {
    // handle the error
}

// And more ...
// @see https://flysystem.thephpleague.com/v2/docs/usage/filesystem-api/
```

Sets a custom default filesystem
--------------------------------

[](#sets-a-custom-default-filesystem)

The default disk is created from public dir of the web application, it accessible via native PHP function [getcwd](https://www.php.net/manual/function.getcwd.php). But the risk is that you could delete, overwrite ... files essential to the functioning of your application.

For this security convenients, it is preferable to config your own default fallback disk with better file permissions.

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$defaultDisk = $storage->createLocalFilesystem('/my/secured/fallback/directory/absolute_path');

$storage->setDefaultDisk($defaultDisk);
```

Register a local disk
---------------------

[](#register-a-local-disk)

### From a local dir path

[](#from-a-local-dir-path)

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$storage->registerLocalDisk('my-local-disk', '/my/local/directory/absolute_path');
```

### With a custom local filesystem instance

[](#with-a-custom-local-filesystem-instance)

```
use Pollen\Filesystem\LocalFilesystem;
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$filesystem = new LocalFilesystem($storage->createLocalAdapter('/my/local/directory/absolute_path'));

$storage->addDisk('my-local-disk', $filesystem);
```

### With a custom local filesystem instance and with custom adapter instance

[](#with-a-custom-local-filesystem-instance-and-with-custom-adapter-instance)

More information about filesystem architecture on [Flysystem online official documentation](https://flysystem.thephpleague.com/v2/docs/architecture/).

```
use Pollen\Filesystem\LocalFilesystemAdapter;
use Pollen\Filesystem\LocalFilesystem;
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$adapter = new LocalFilesystemAdapter('/my/local/directory/absolute_path');
$filesystem = new LocalFilesystem($adapter);

$storage->addDisk('my-local-disk', $localDisk);
```

Extended Local Filesystem API.
------------------------------

[](#extended-local-filesystem-api)

One of the main advantages of using Pollen Solutions Filesystem instead Flysystem, is that it is coupled with a system of HTTP request. This allows to extend the API of Flystem with some practical features.

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$disk = $storage->registerLocalDisk('my-local-disk', '/my/local/directory/absolute_path');

// Returns the HTTP response to download a file.
$disk->downloadResponse('/sample.txt');

// Returns the HTTP binary file response to download a file.
$disk->binaryFileResponse('/sample.txt');

// Returns the url of a file or a directory.
$disk->getUrl('/sample.txt')

// Gets the absolute path of a file or a directory.
$disk->getAbsolutePath('/sample.txt');

// Gets the SplFileInfo instance of a file or a directory.
$disk->getSplFileInfo('/sample.txt');

// Gets the storage file attributes of a file or a directory.
$disk->getStorageAttributes('/sample.txt');
```

Local Image Filesystem
----------------------

[](#local-image-filesystem)

Pollen Solutions Filesystem provides a specific Filesystem and its adapter for the local image files.

### Register a local image filesystem

[](#register-a-local-image-filesystem)

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$filesystem = $storage->registerLocalImageDisk('my-image-disk', '/my/image/directory/absolute_path'));
```

### Create a custom local image filesystem instance

[](#create-a-custom-local-image-filesystem-instance)

```
use Pollen\Filesystem\LocalImageFilesystem;
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$filesystem = new LocalImageFilesystem($storage->createLocalAdapter('/my/image/directory/absolute_path'));

$storage->addLocalDisk('my-image-disk', $filesystem);
```

### Local Image Filesystem extended API

[](#local-image-filesystem-extended-api)

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$disk = $storage->registerLocalImageDisk('my-image-disk', '/my/image/directory/absolute_path'));

// Gets the HTML render of an image file from its path.
$disk->HtmlRender('/sample.jpg');

// Gets the image file url from its path.
$disk->getImgSrc('/sample.jpg');
```

S3 Filesystem
-------------

[](#s3-filesystem)

```
use Pollen\Filesystem\StorageManagerInterface;

/** @var StorageManagerInterface $storage */
$disk = $storage->registerS3Disk(
    's3-disk',
    [
        'version'     => 'latest',
        'region'      => 'us-east-2',
        'endpoint'    => '{{ my-s3-endpoint }}',
        'credentials' => [
            'key'    => '{{ my-s3-user }}',
            'secret' => '{{ my-s3-user-password }}',
        ]
    ],
    'my-aws-s3-bucket-name'
);

if ($disk = $storage->disk('s3-disk')) {
    try {
        $listing = $disk->listContents('/';

        /** @var \League\Flysystem\StorageAttributes $item */
        foreach ($listing as $item) {
            $path = $item->path();

            if ($item instanceof FileAttributes) {
                var_dump($path);
            } elseif ($item instanceof DirectoryAttributes) {
                var_dump($path);
            }
        }
    } catch (FilesystemException $e) {
        var_dump($e->getMessage());
    }
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Uses native or third-party Filesystem and Adapter

[](#uses-native-or-third-party-filesystem-and-adapter)

Flysystem has a variety of Filesystems and adapters, sometimes provided by third party library.

Examples :

- [Aws S3 (v3) Adapter](https://flysystem.thephpleague.com/v2/docs/adapter/aws-s3-v3/)
- [Gitlab storage](https://github.com/RoyVoetman/flysystem-gitlab-storage)
- ...

You might need to use one of them and implement it in Pollen Solutions Filesystem Component.

This example uses Flysystem FTP Adapter. First of all, Flysystem FTP Adapter requires a new dependency installation.

```
composer require league/flysystem-ftp:^2.0
```

```
use Pollen\Filesystem\Filesystem;
use Pollen\Filesystem\StorageManagerInterface;

// The internal adapter
$adapter = new \League\Flysystem\Ftp\FtpAdapter(
    // Connection options
    \League\Flysystem\Ftp\FtpConnectionOptions::fromArray([
        'host' => 'hostname', // required
        'root' => '/root/path/', // required
        'username' => 'username', // required
        'password' => 'password', // required
        'port' => 21,
        'ssl' => false,
        'timeout' => 90,
        'utf8' => false,
        'passive' => true,
        'transferMode' => FTP_BINARY,
        'systemType' => null, // 'windows' or 'unix'
        'ignorePassiveAddress' => null, // true or false
        'timestampsOnUnixListingsEnabled' => false, // true or false
        'recurseManually' => true // true
    ])
);

$filesystem = new Filesystem($adapter);

/** @var StorageManagerInterface $storage */
$storage->addDisk('ftp-disk', $filesystem);

if ($disk = $storage->disk('ftp-disk')) {
    try {
        $listing = $disk->listContents('/');

        /** @var \League\Flysystem\StorageAttributes $item */
        foreach ($listing as $item) {
            $path = $item->path();

            if ($item instanceof \League\Flysystem\FileAttributes) {
                var_dump($path);
            } elseif ($item instanceof \League\Flysystem\DirectoryAttributes) {
                var_dump($path);
            }
        }
    } catch (\League\Flysystem\FilesystemException $e) {
        var_dump($e->getMessage());
    }
}
```

### Create your own filesystem driver

[](#create-your-own-filesystem-driver)

```
use Pollen\Filesystem\StorageManagerInterface;
use Pollen\Filesystem\FilesystemDriver;
use League\Flysystem\Ftp\FtpAdapter;
use League\Flysystem\Ftp\FtpConnectionOptions;

$driver = new class extends FilesystemDriver
{
    protected ?string $adapterDefinition = FtpAdapter::class

    /**
     * @inheritDoc
     *
     * {@internal Allows to pass and parse an array of connection options.}
     */
    public function parseArgs(...$args) : array{
        if (!isset($args[0]) || !is_array($args)) {
            throw new RuntimeException('FTP Filesystem first argument could be an array of connection options.');
        }

        $config = $args[0];
        $config['host'] = $config['host']?? '127.0.0.1';
        $config['root'] = $config['root']?? '/';
        $config['username'] = $config['username'] ?? 'root';
        $config['password'] = $config['password'] ?? 'root';

        $_args[] = FtpConnectionOptions::fromArray($config);

        return $_args;
    }
};

/** @var StorageManagerInterface $storage */
$storage->registerDriver('ftp', $driver);

$storage->registerDisk('ftp-disk', 'ftp', [
    'host'      => 'hostname', // required
    'root'      => '/root/path/', // required
    'username'  => 'username', // required
    'password'  => 'password', // required
]);

if ($disk = $storage->disk('ftp-disk')) {
    try {
        $listing = $disk->listContents('/', true);

        /** @var \League\Flysystem\StorageAttributes $item */
        foreach ($listing as $item) {
            $path = $item->path();

            if ($item instanceof \League\Flysystem\FileAttributes) {
                var_dump($path);
            } elseif ($item instanceof \League\Flysystem\DirectoryAttributes) {
                var_dump($path);
            }
        }
    } catch (\League\Flysystem\FilesystemException $e) {
        var_dump($e->getMessage());
    }
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

1727d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1d9488545d6b446f8df86ec373a070e7fed1166fc47e1324d963e46d3d838d3?d=identicon)[presstify](/maintainers/presstify)

---

Top Contributors

[![jordy-manner](https://avatars.githubusercontent.com/u/733356?v=4)](https://github.com/jordy-manner "jordy-manner (4 commits)")

---

Tags

filesystemphpfilesystemcomponentpollen-solutions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pollen-solutions-filesystem/health.svg)

```
[![Health](https://phpackages.com/badges/pollen-solutions-filesystem/health.svg)](https://phpackages.com/packages/pollen-solutions-filesystem)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[oneup/flysystem-bundle

Integrates Flysystem filesystem abstraction library to your Symfony project.

64422.9M66](/packages/oneup-flysystem-bundle)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M87](/packages/league-flysystem-bundle)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
