PHPackages                             acidwave/yii2-flysystem - 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. acidwave/yii2-flysystem

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

acidwave/yii2-flysystem
=======================

The flysystem extension for the Yii framework

v1.0.1(4y ago)02.8kBSD-3-ClausePHPPHP ^7.2 || ^8.0

Since Nov 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/acidwave/yii2-flysystem)[ Packagist](https://packagist.org/packages/acidwave/yii2-flysystem)[ RSS](/packages/acidwave-yii2-flysystem/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Flysystem Extension for Yii 2
=============================

[](#flysystem-extension-for-yii-2)

[![Code Quality](https://camo.githubusercontent.com/f9b3bbb16ac074cae41216f1f8a488369fcd78376aaf86d651a9f6f049d4b89d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f61636964776176652f796969322d666c7973797374656d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/acidwave/yii2-flysystem/?branch=master)[![Packagist Version](https://camo.githubusercontent.com/1cd9f78540cfff902710698cb9e75452eb848c838c038e73fb692f449da7aca2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61636964776176652f796969322d666c7973797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/acidwave/yii2-flysystem)[![Total Downloads](https://camo.githubusercontent.com/b01e96f86e8ce99674349ca9812ea32e07d718dfb6e2925ffd1412dee2440112/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61636964776176652f796969322d666c7973797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/acidwave/yii2-flysystem)

This extension provides [Flysystem](http://flysystem.thephpleague.com/) integration for the Yii framework. [Flysystem](http://flysystem.thephpleague.com/) is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require acidwave/yii2-flysystem
```

or add

```
"acidwave/yii2-flysystem": "1.0.*"

```

to the `require` section of your `composer.json` file.

Configuring
-----------

[](#configuring)

### Local filesystem

[](#local-filesystem)

Configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'Acidwave\Flysystem\LocalFilesystem',
            'path' => '@webroot/files',
        ],
    ],
];
```

### FTP filesystem

[](#ftp-filesystem)

Configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'ftpFs' => [
            'class' => 'Acidwave\Flysystem\FtpFilesystem',
            'host' => 'ftp.example.com',
            // 'port' => 21,
            'username' => 'your-username',
            'password' => 'your-password',
            // 'ssl' => true,
            // 'timeout' => 60,
            'root' => '/path/to/root',
            // 'passive' => false,
            // 'transferMode' => FTP_TEXT,
            // 'enableTimestampsOnUnixListings' => false,
            // 'systemType' => null, // 'windows' or 'unix'
        ],
    ],
];
```

### AWS S3 filesystem

[](#aws-s3-filesystem)

Either run

```
$ composer require league/flysystem-aws-s3-v3
```

or add

```
"league/flysystem-aws-s3-v3": "^2.0"

```

to the `require` section of your `composer.json` file and configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'awss3Fs' => [
            'class' => 'Acidwave\Flysystem\AwsS3Filesystem',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'bucket' => 'your-bucket',
            'region' => 'your-region',
            // 'version' => 'latest',
            // 'baseUrl' => 'your-base-url',
            // 'prefix' => 'your-prefix',
            // 'visibility' => \League\Flysystem\Visibility::PUBLIC,
            // 'endpoint' => 'http://my-custom-url'
        ],
    ],
];
```

### Dropbox filesystem

[](#dropbox-filesystem)

Either run

```
$ composer require league/flysystem-dropbox
```

or add

```
"league/flysystem-dropbox": "^2.0"

```

to the `require` section of your `composer.json` file and configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'dropboxFs' => [
            'class' => 'Acidwave\Flysystem\DropboxFilesystem',
            'token' => 'your-token',
            // 'prefix' => 'your-prefix',
        ],
    ],
];
```

### SFTP filesystem

[](#sftp-filesystem)

Either run

```
$ composer require league/flysystem-sftp
```

or add

```
"league/flysystem-sftp": "^2.0"

```

to the `require` section of your `composer.json` file and configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'sftpFs' => [
            'class' => 'Acidwave\Flysystem\SftpFilesystem',
            'host' => 'sftp.example.com',
            // 'port' => 22,
            'username' => 'your-username',
            'password' => 'your-password',
            'privateKey' => '/path/to/or/contents/of/privatekey',
            'passphrase' => 'my-super-secret-passphrase-for-the-private-key',
            // 'useAgent' => false,
            // 'timeout' => 60,
            'root' => '/path/to/root',
            // 'dirPrivate' => 0700,
            // 'dirPublic' => 0755,
            // 'filePrivate' => 0600,
            // 'filePublic' => 0644,
        ],
    ],
];
```

### ZipArchive filesystem

[](#ziparchive-filesystem)

Either run

```
$ composer require league/flysystem-ziparchive
```

or add

```
"league/flysystem-ziparchive": "^2.0"

```

to the `require` section of your `composer.json` file and configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        'ziparchiveFs' => [
            'class' => 'Acidwave\Flysystem\ZipArchiveFilesystem',
            'filename' => '@webroot/files/archive.zip',
            // 'localDirectoryPermissions' => 700,
        ],
    ],
];
```

### Global visibility settings

[](#global-visibility-settings)

Configure `fsID` application component as follows

```
return [
    //...
    'components' => [
        //...
        'fsID' => [
            //...
            'config' => [
                'visibility' => \League\Flysystem\Visibility::PRIVATE,
            ],
        ],
    ],
];
```

Usage
-----

[](#usage)

### Writing files

[](#writing-files)

To write file

```
Yii::$app->fs->write('filename.ext', 'contents');
```

To write file using stream contents

```
$stream = fopen('/path/to/somefile.ext', 'r+');
Yii::$app->fs->writeStream('filename.ext', $stream);
```

### Reading files

[](#reading-files)

To read file

```
$contents = Yii::$app->fs->read('filename.ext');
```

To retrieve a read-stream

```
$stream = Yii::$app->fs->readStream('filename.ext');
$contents = stream_get_contents($stream);
fclose($stream);
```

### Checking if a file exists

[](#checking-if-a-file-exists)

To check if a file exists

```
$exists = Yii::$app->fs->fileExists('filename.ext');
```

### Deleting files

[](#deleting-files)

To delete file

```
Yii::$app->fs->delete('filename.ext');
```

### Renaming files

[](#renaming-files)

To rename file

```
Yii::$app->fs->move('filename.ext', 'newname.ext');
```

### Getting files mimetype

[](#getting-files-mimetype)

To get file mimetype

```
$mimetype = Yii::$app->fs->mimeType('filename.ext');
```

### Getting files timestamp

[](#getting-files-timestamp)

To get file timestamp

```
$timestamp = Yii::$app->fs->lastModified('filename.ext');
```

### Getting files size

[](#getting-files-size)

To get file size

```
$timestamp = Yii::$app->fs->fileSize('filename.ext');
```

### Creating directories

[](#creating-directories)

To create directory

```
Yii::$app->fs->createDirectory('path/to/directory');
```

Directories are also made implicitly when writing to a deeper path

```
Yii::$app->fs->write('path/to/filename.ext');
```

### Deleting directories

[](#deleting-directories)

To delete directory

```
Yii::$app->fs->deleteDirectory('path/to/filename.ext');
```

### Managing visibility

[](#managing-visibility)

Visibility is the abstraction of file permissions across multiple platforms. Visibility can be either public or private.

```
use League\Flysystem\Visibility;

Yii::$app->fs->write('filename.ext', 'contents', [
    'visibility' => Visibility::PRIVATE
]);
```

You can also change and check visibility of existing files

```
use League\Flysystem\Visibility;

if (Yii::$app->fs->visibility('filename.ext') === Visibility::PRIVATE) {
    Yii::$app->fs->setVisibility('filename.ext', Visibility::PUBLIC);
}
```

### Listing contents

[](#listing-contents)

To list contents

```
$contents = Yii::$app->fs->listContents('path/to/directory');

foreach ($contents as $object) {
    echo basename($object->path())
        . ' is located at' . $object->path()
        . ' and is a ';
    if ($object instanceof \League\Flysystem\FileAttributes) {
        echo 'file' . PHP_EOF;
    } elseif ($object instanceof \League\Flysystem\DirectoryAttributes) {
        echo 'directory' . PHP_EOF;
    }
}
```

By default Flysystem lists the top directory non-recursively. You can supply a directory name and recursive boolean to get more precise results

```
$contents = Yii::$app->fs->listContents('path/to/directory', true);
```

Donating
--------

[](#donating)

Support this project and [others by acidwave](https://liberapay.com/acidwave/) via [Liberapay](https://liberapay.com/acidwave/).

[![Support via Liberapay](https://camo.githubusercontent.com/f42d4c8650291eed95d5feb7658604d653ad107d3308fb7e8f269623d7ed65cf/68747470733a2f2f6c69626572617061792e636f6d2f6173736574732f776964676574732f646f6e6174652e737667)](https://liberapay.com/acidwave/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

1652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b355020ad27f4078d4bf20f12be12aab7b58a64b5ff7c166bd4788e56bd39ae?d=identicon)[acidwave](/maintainers/acidwave)

---

Tags

ftpfilesystemFlysystemawssftpfilesWebDAVyii2dropbox

### Embed Badge

![Health badge](/badges/acidwave-yii2-flysystem/health.svg)

```
[![Health](https://phpackages.com/badges/acidwave-yii2-flysystem/health.svg)](https://phpackages.com/packages/acidwave-yii2-flysystem)
```

###  Alternatives

[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

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

SFTP filesystem adapter for Flysystem.

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

WebDAV filesystem adapter for Flysystem.

762.3M56](/packages/league-flysystem-webdav)

PHPackages © 2026

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