Yii2 Flysystem component
, (*1)
Yii2 component for working with league/flysystem., (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
composer require consik/yii2-flysystem
or add, (*5)
"consik/yii2-flysystem": "^1.0"
Using
Define component in yii config for your filesystem:, (*6)
//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:, (*7)
\Yii::$app->localFiles->listFiles();
...etc
See DocBlock for more info about configuration params., (*8)
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, (*9)
That's all! Enjoy!, (*10)