consik/yii2-flysystem

Yii2 flysystem component

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0 2017-03-01 15:00 UTC

This package is not auto-updated.

Last update: 2024-12-21 22:03:05 UTC


README

Latest Stable Version Total Downloads License

Yii2 component for working with league/flysystem.

Installation

The preferred way to install this extension is through composer.

Either run

composer require consik/yii2-flysystem

or add

"consik/yii2-flysystem": "^1.0"

Using

Define component in yii config for your filesystem:

//config/web.php for simple application
'components' => [
    ... 
    'localFiles' => [
        'class' => consik\yii2flysystem\Filesystem::class,
        'adapter' => \League\Flysystem\Adapter\Local::class,
        'adapterParams' => [
            __DIR__ //first argument for Local adapter constructor is root dir
        ],
        'plugins' => [
            \League\Flysystem\Plugin\ListFiles::class
        ]
        //'config' => [] //\League\Flysystem\Filesystem config param
    ]
    ...
]

Use Filesystem methods via this component:

\Yii::$app->localFiles->listFiles();
...etc

See DocBlock for more info about configuration params.

FTP source example:

'components' => [
    ... 
    'ftp' => [
        'class' => consik\yii2flysystem\Filesystem::class,
        'adapter' => \League\Flysystem\Adapter\Ftp::class,
        'adapterParams' => [
            [ //for FTP constructor first param is configuration array
                'host' => 'your.ftp.host',
                'username' => 'username',
                'password' => 'password'
            ]
        ],
        'plugins' => [
            \League\Flysystem\Plugin\ListFiles::class
        ]
    ]
    ...
]

List of available adapters or plugins see on official flysystem page: https://github.com/thephpleague/flysystem

That's all! Enjoy!