possibilitycompany / yii2-resource-manager-component
Resource manager eases your project resources management.
Installs: 207
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Type:yii2-extension
Requires
- aws/aws-sdk-php: 3.178.6
- yiisoft/yii2: *
README
This extension allows you to manage resources. Currently supports two possible scenarios:
- Resources to save/or saved on a server's folder
- Resources to save/or saved on an Amazon S3 bucket
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require possibilitycompany/yii2-resource-manager-component "*"
or add
"possibilitymovement/yii2-resource-manager-component": "*"
to the require section of your composer.json
file.
Configuring
Configure the selected component on your configuration file as follows:
// For this example we using AmazonS3ResourceManager component
// ...
'components' => [
// ...
'resourceManager' => [
'class' => 'possibilitymovement\resourcemanager\AmazonS3ResourceManager',
'key' => 'YOUR-AWS-KEY-HERE',
'secret' => 'YOUR-AWS-SECRET-HERE',
'bucket' => 'YOUR-AWS-BUCKET-NAME-HERE'
]
// ...
]
// ...
Done... Now, to save a resource to AWS S3 server, we just need to do the following:
// Defensive code checks not written for the example
$resource = yii\web\UploadedFile::getInstanceByName('instance-name');
$name = md5($resource->name) . '.' . $resource->getExtension();
if(\Yii::$app->resourceManager->save($resource, $name)) {
echo 'Done...';
}
Notes
Looking for a version for the Yii 1.1? There is dedicated repository for it: possibilitymovement/resource-manager.
Web development has never been so fun!
www.2amigos.us