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

ActiveYii2-extension

sorokinmedia/yii2-flysystem
===========================

The flysystem extension(digitalocean spaces) for the Yii framework

039PHP

Since Jan 4Pushed 6y agoCompare

[ Source](https://github.com/sorokinmedia/yii2-flysystem)[ Packagist](https://packagist.org/packages/sorokinmedia/yii2-flysystem)[ RSS](/packages/sorokinmedia-yii2-flysystem/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

[![Total Downloads](https://camo.githubusercontent.com/c3b1230bcd5566d3d5416990280daa2b135374bc2e469f3bc5ce620f2679771a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f726f6b696e6d656469612f796969322d666c7973797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sorokinmedia/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 sorokinmedia/yii2-flysystem
```

or add

```
"sorokinmedia/yii2-flysystem": "dev-master"

```

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

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

[](#configuring)

### Local filesystem

[](#local-filesystem)

Configure application `components` as follows

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

### AWS S3 filesystem

[](#aws-s3-filesystem)

Either run

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

or add

```
"league/flysystem-aws-s3-v3": "~1.0"

```

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

```
return [
    //...
    'components' => [
        //...
        'awss3Fs' => [
            'class' => 'sorokinmedia\flysystem\AwsS3Filesystem',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'bucket' => 'your-bucket',
            'region' => 'your-region',
            // 'version' => 'latest',
            // 'baseUrl' => 'your-base-url',
            // 'prefix' => 'your-prefix',
            // 'options' => [],
            // 'endpoint' => 'http://my-custom-url'
        ],
    ],
];
```

### Caching feature

[](#caching-feature)

Either run

```
$ composer require league/flysystem-cached-adapter
```

or add

```
"league/flysystem-cached-adapter": "~1.0"

```

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

```
return [
    //...
    'components' => [
        //...
        'fsID' => [
            //...
            'cache' => 'cacheID',
            // 'cacheKey' => 'flysystem',
            // 'cacheDuration' => 3600,
        ],
    ],
];
```

### Global visibility settings

[](#global-visibility-settings)

Configure `fsID` application component as follows

```
return [
    //...
    'components' => [
        //...
        'fsID' => [
            //...
            'config' => [
                'visibility' => \League\Flysystem\AdapterInterface::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);
```

### Updating files

[](#updating-files)

To update file

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

To update file using stream contents

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

### Writing or updating files

[](#writing-or-updating-files)

To write or update file

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

To write or update file using stream contents

```
$stream = fopen('/path/to/somefile.ext', 'r+');
Yii::$app->fs->putStream('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->has('filename.ext');
```

### Deleting files

[](#deleting-files)

To delete file

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

### Reading and deleting files

[](#reading-and-deleting-files)

To read and delete file

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

### Renaming files

[](#renaming-files)

To rename file

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

### Getting files mimetype

[](#getting-files-mimetype)

To get file mimetype

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

### Getting files timestamp

[](#getting-files-timestamp)

To get file timestamp

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

### Getting files size

[](#getting-files-size)

To get file size

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

### Creating directories

[](#creating-directories)

To create directory

```
Yii::$app->fs->createDir('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->deleteDir('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\AdapterInterface;

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

You can also change and check visibility of existing files

```
use League\Flysystem\AdapterInterface;

if (Yii::$app->fs->getVisibility('filename.ext') === AdapterInterface::VISIBILITY_PRIVATE) {
    Yii::$app->fs->setVisibility('filename.ext', AdapterInterface::VISIBILITY_PUBLIC);
}
```

### Listing contents

[](#listing-contents)

To list contents

```
$contents = Yii::$app->fs->listContents();

foreach ($contents as $object) {
    echo $object['basename']
        . ' is located at' . $object['path']
        . ' and is a ' . $object['type'];
}
```

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);
```

### Listing paths

[](#listing-paths)

To list paths

```
$paths = Yii::$app->fs->listPaths();

foreach ($paths as $path) {
    echo $path;
}
```

### Listing with ensured presence of specific metadata

[](#listing-with-ensured-presence-of-specific-metadata)

To list with ensured presence of specific metadata

```
$listing = Yii::$app->fs->listWith(
    ['mimetype', 'size', 'timestamp'],
    'optional/path/to/directory',
    true
);

foreach ($listing as $object) {
    echo $object['path'] . ' has mimetype: ' . $object['mimetype'];
}
```

### Getting file info with explicit metadata

[](#getting-file-info-with-explicit-metadata)

To get file info with explicit metadata

```
$info = Yii::$app->fs->getWithMetadata('path/to/filename.ext', ['timestamp', 'mimetype']);
echo $info['mimetype'];
echo $info['timestamp'];
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.3% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6071315?v=4)[Ruslan Gilyazetdinov](/maintainers/Ma3oBblu)[@Ma3oBblu](https://github.com/Ma3oBblu)

---

Top Contributors

[![creocoder](https://avatars.githubusercontent.com/u/896494?v=4)](https://github.com/creocoder "creocoder (151 commits)")[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (11 commits)")[![Ma3oBblu](https://avatars.githubusercontent.com/u/6071315?v=4)](https://github.com/Ma3oBblu "Ma3oBblu (5 commits)")[![pgaultier](https://avatars.githubusercontent.com/u/545714?v=4)](https://github.com/pgaultier "pgaultier (2 commits)")[![kesselb](https://avatars.githubusercontent.com/u/3902676?v=4)](https://github.com/kesselb "kesselb (2 commits)")[![k-timoshenko](https://avatars.githubusercontent.com/u/3259675?v=4)](https://github.com/k-timoshenko "k-timoshenko (1 commits)")[![dizews](https://avatars.githubusercontent.com/u/452641?v=4)](https://github.com/dizews "dizews (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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