This commit is contained in:
Milos Stojanovic
2019-06-18 14:27:31 +02:00
parent 7f3e111d49
commit f8940c8713
9 changed files with 179 additions and 234 deletions

View File

@@ -0,0 +1,102 @@
## Adapters
Different storage adapters are supported via awesome [Flysystem](https://github.com/thephpleague/flysystem) library.
You can use local filesystem (default), FTP, S3, Dropbox and many others. Please check Flysystem for exact setup for each adapter.
## Default Local Disk Adapter
With default adapter you just need to configure where is you ```repository``` folder which will serve as root for everything else.
```
'Filegator\Services\Storage\Filesystem' => [
'handler' => '\Filegator\Services\Storage\Filesystem',
'config' => [
'separator' => '/',
'config' => [],
'filesystem_adapter' => 'localfilesystem',
'adapters' => [
'localfilesystem' => function () {
return new \League\Flysystem\Adapter\Local(
__DIR__.'/repository'
);
},
],
],
],
```
## FTP Adapter
See official [documentation](https://flysystem.thephpleague.com/docs/adapter/ftp/)
```
'Filegator\Services\Storage\Filesystem' => [
'handler' => '\Filegator\Services\Storage\Filesystem',
'config' => [
'separator' => '/',
'config' => [],
'filesystem_adapter' => 'ftp',
'adapters' => [
'ftp' => function () {
return new \League\Flysystem\Adapter\Ftp([
'host' => 'example.com',
'username' => 'demo',
'password' => 'password',
'port' => 21,
'timeout' => 10,
]);
},
],
],
],
```
## SFTP Adapter
You must require additional library ```composer require league/flysystem-sftp```.
See official [documentation](https://flysystem.thephpleague.com/docs/adapter/sftp/).
```
'Filegator\Services\Storage\Filesystem' => [
'handler' => '\Filegator\Services\Storage\Filesystem',
'config' => [
'separator' => '/',
'config' => [],
'filesystem_adapter' => 'sftp',
'adapters' => [
'sftp' => function () {
return new \League\Flysystem\Sftp\SftpAdapter([
'host' => 'example.com',
'port' => 22,
'username' => 'demo',
'password' => 'password',
'timeout' => 10,
]);
},
],
],
],
```
## Dropbox Adapter
You must require additional library ```composer require spatie/flysystem-dropbox```.
See official [documentation](https://flysystem.thephpleague.com/docs/adapter/dropbox/)
```
'Filegator\Services\Storage\Filesystem' => [
'handler' => '\Filegator\Services\Storage\Filesystem',
'config' => [
'separator' => '/',
'config' => [],
'filesystem_adapter' => 'dropbox',
'adapters' => [
'dropbox' => function () {
$authorizationToken = '1234';
$client = new \Spatie\Dropbox\Client($authorizationToken);
return new \Spatie\FlysystemDropbox\DropboxAdapter($client);
},
],
],
],
```