PHP code example of 2amigos / yii2-flysystem-component
1. Go to this page and download the library: Download 2amigos/yii2-flysystem-component library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
2amigos / yii2-flysystem-component example snippets
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\AwsS3FsComponent',
'key' => 'your-key',
'secret' => 'your-secret',
'bucket' => 'your-bucket',
'region' => 'your-region',
// 'version' => 'latest',
// 'baseUrl' => 'your-base-url',
// 'prefix' => 'your-prefix',
// 'options' => [],
],
],
];
Yii::$app->fs->read(....);
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\AzureFsComponent',
'accountName' => 'your-account-name',
'accountKey' => 'your-account-key',
'container' => 'your-container',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\DropboxFsComponent',
'token' => 'your-access-token',
// 'prefix' => 'your-prefix',
],
],
];
return [
//...
'components' => [
//...
'ftpFs' => [
'class' => 'dosamigos\flysystem\FtpFsComponent',
'host' => 'ftp.example.com',
// 'port' => 21,
// 'username' => 'your-username',
// 'password' => 'your-password',
// 'ssl' => true,
// 'timeout' => 60,
// 'root' => '/path/to/root',
// 'permPrivate' => 0700,
// 'permPublic' => 0744,
// 'passive' => false,
// 'transferMode' => FTP_TEXT,
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\GoogleCloudFsComponent',
'projectId' => 'your-project-id',
'bucket' => 'your-bucket',
// 'prefix' => 'your-prefix',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\GridFSFsComponent',
'server' => 'mongodb://localhost:27017',
'database' => 'your-database',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\LocalFsComponent',
'path' => '@webroot/your-writable-folder-to-save-files',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\MemoryFsComponent',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\NullFsComponent',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\RackspaceFsComponent',
'endpoint' => 'your-endpoint',
'region' => 'your-region',
'username' => 'your-username',
'apiKey' => 'your-api-key',
'container' => 'your-container',
// 'prefix' => 'your-prefix',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\SftpFsComponent',
'host' => 'sftp.example.com',
'username' => 'your-username',
'password' => 'your-password',
'privateKey' => '/path/to/or/contents/of/privatekey',
// 'port' => 22,
// 'timeout' => 60,
// 'root' => '/path/to/root',
// 'permPrivate' => 0700,
// 'permPublic' => 0744,
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\WebDAVFsComponent',
'baseUri' => 'your-base-uri',
// 'userName' => 'your-user-name',
// 'password' => 'your-password',
// 'proxy' => 'your-proxy',
// 'authType' => \Sabre\DAV\Client::AUTH_BASIC,
// 'encoding' => \Sabre\DAV\Client::ENCODING_IDENTITY,
// 'prefix' => 'your-prefix',
],
],
];
return [
//...
'components' => [
//...
'fs' => [
'class' => 'dosamigos\flysystem\ZipArchiveFsComponent',
'path' => '@webroot/files/archive.zip',
// 'prefix' => 'your-prefix',
],
],
];
return [
//...
'components' => [
//...
's3Fs' => [
'class' => 'dosamigos\flysystem\AwsS3FsComponent',
'key' => 'your-key',
'secret' => 'your-secret',
'bucket' => 'your-bucket',
'region' => 'your-region',
// 'version' => 'latest',
// 'baseUrl' => 'your-base-url',
// 'prefix' => 'your-prefix',
// 'options' => [],
],
'ftpFs => [
'class' => 'dosamigos\flysystem\FtpFsComponent',
'host' => 'ftp.example.com',
]
],
];
return [
//...
'components' => [
//...
'fs' => [
//...
'cache' => 'cacheID',
// 'cacheKey' => 'my-cache-key',
// 'cacheDuration' => 7200,
],
],
];
return [
//...
'components' => [
//...
's3Fs' => [
'class' => 'dosamigos\flysystem\AwsS3FsComponent',
'key' => 'your-key',
'secret' => 'your-secret',
'bucket' => 'your-bucket',
'region' => 'your-region',
],
'ftpFs => [
'class' => 'dosamigos\flysystem\FtpFsComponent',
'host' => 'ftp.example.com',
'replica' => 's3Fs' // we have added the ID of the replica component
]
],
];
"repositories": [
{
"type": "pear",
"url": "http://pear.php.net"
}
],
bash
./vendor/bin/php-cs-fixer fix ./src --config .php_cs