PHP code example of mhunesi / yii2-storage
1. Go to this page and download the library: Download mhunesi/yii2-storage 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/ */
mhunesi / yii2-storage example snippets
'components' => [
//...
'storage' => [
'class' => '\mhunesi\storage\Storage',
'defaultStorage' => 'local',
'queueFilters' => true,
'queueFiltersList' => ['tiny-crop', 'medium-thumbnail'],
'downloadValidationKey' => 'YII_STORAGE_KEY',
'downloadUrl' => '/site/download',
'storages' => [
'local' => [
'class' => '\mhunesi\storage\filesystem\LocalFilesystem',
'path' => '@app/web/uploads',
'cache' => 'cache',
'cacheKey' => 'filesystem_file',
//'replica' => 'minio',
'replica' => [
'class' => '\mhunesi\storage\filesystem\LocalFilesystem',
'path' => '@app/web/uploads2',
'cache' => 'cache',
'cacheKey' => 'filesystem_file_2',
]
],
'aws' => [
'class' => 'mhunesi\storage\filesystem\AwsS3Filesystem',
'bucket' => 'bucket_name',
'key' => '_key',
'secret' => 'secret_key',
'region' => 'eu-central-1',
// 'version' => 'latest',
'prefix' => 'wss',
'cache' => 'cache',
'cacheKey' => 'filesystem_aws',
'replica' => [
'class' => '\mhunesi\storage\filesystem\LocalFilesystem',
'path' => '@app/web/uploads2',
'cache' => 'cache',
'cacheKey' => 'filesystem_file_2',
],
],
'minio' => [
'class' => 'mhunesi\storage\filesystem\AwsS3Filesystem',
'bucket' => 'bucket_name',
'key' => '_key',
'secret' => 'scret_key',
'region' => 'eu-central-1',
// 'version' => 'latest',
// 'baseUrl' => 'your-base-url',
'prefix' => 'subfolder',
// 'options' => [],
'endpoint' => 'http://127.0.0.1:49160',
'cache' => 'cache',
'cacheKey' => 'filesystem_minio'
],
'ftp' => [
'class' => 'mhunesi\storage\filesystem\FtpFilesystem',
'host' => '192.168.1.1',
'port' => 21,
'username' => 'ftp_username',
'password' => 'ftp_password',
'cache' => 'cache',
'cacheKey' => 'filesystem_ftp1',
// 'ssl' => true,
// 'timeout' => 60,
'root' => '/rootPath',
'publicUrl' => 'http://ftp_url/',
// 'permPrivate' => 0700,
// 'permPublic' => 0744,
// 'passive' => false,
// 'transferMode' => FTP_TEXT,
'replica' => 'local',
],
]
]
//...
],
'controllerMap' => [
'migrate' => [
//..
'migrationNamespaces' => [
//..
],
'migrationPath' => [
//..
'@mhunesi/storage/migrations'
]
]
],
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'download' => [
'class' => 'mhunesi\storage\actions\DownloadAction',
],
'upload' => [
'class' => 'mhunesi\storage\actions\FileUploadAction',
'use_strict' => true,
'path' => 'folder/folder',
'folder' => 1,
'hidden' => true,
'visibility' => AdapterInterface::VISIBILITY_PUBLIC
],
];
}
'rules' => [
'download/<token:[a-zA-Z0-9_\-\+\%\/=]*>/<filename:[a-zA-Z0-9_\-\+\%\.\ \/=]*>' => 'site/download'
]
php composer.phar