airani/yii2-flysystem Yii2 Flysystem Component

componentflysystemfilesystem

Yii2 Flysystem Component

The Flysystem component for Yii2 PHP framework with more flexibility than similar components and integrated with Flysystem MountManager and returns Flysystem objects as Yii2 component that helps to work with other libraries integrated with Flysystem like Glide .

Installation

The preferred way to install this extension is through composer .

Either run

composer require airani/yii2-flysystem

or add

"airani/yii2-flysystem": "~1.0"

to the require section of your composer.json file.

Configuring

Configure application components for any of filesystem adapter as follows

return [
    // ...
    'componenets' => [
        // ...
        'flysystem' => [
            'class' => 'airani\flysystem\MountManager',
            'localFs' => [ // https://flysystem.thephpleague.com/adapter/local/
                'class' => 'League\Flysystem\Adapter\Local',
                'root' => __DIR__.'/path/to/too',
            ],
            'ftpFs' => [ // https://flysystem.thephpleague.com/adapter/ftp/
                'class' => 'League\Flysystem\Adapter\Ftp',
                'config' => [
                    'host' => 'ftp.example.com',
                    'username' => 'username',
                    'password' => 'password',

                    // optional config settings
                    'port' => 21,
                    'root' => '/path/to/root',
                    'passive' => true,
                    'ssl' => true,
                    'timeout' => 30,
                ],
            ],
            // and config other filesystem adapters
            // read adapters section of flysystem guide https://flysystem.thephpleague.com
        ],
    ],
];

Usage

To work with MountManager :

// Read from FTP
$contents = Yii::$app->flysystem->read('ftp://some/file.txt');

// And write to local
Yii::$app->flysystem->write('local://put/it/here.txt', $contents);

Or simple usage:

Yii::$app->filesystem->localFs->write('path/to/file.txt', 'contents');

for how to work with flysystem read this api documentation .

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v1.0 is the latest of one release



BSD-3-Clause license
Stats
7 github stars & 1 github forks
0 downloads in the last day
0 downloads in the last 30 days
184 total downloads