Download the PHP package years/yii2-storage without Composer
On this page you can find all versions of the php package years/yii2-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-storage
Yii2 storege - upload behavior for ActiveRecord
This package is one ActiveRecord behavior. It allows you to keep the uploaded file as-is. It support multiple attributes and files.
Based on Flysystem
, qiniu
and oss
supported.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist years/yii2-storage "*"
or add
"years/yii2-storage": "*"
to the require
section of your composer.json.
Configuration
Add component 'storage'
Add key filesystems
to params.php
UploadBehavior
This behavior allow you to add file uploading logic with ActiveRecord behavior.
Usage
Attach the behavior to your model class:
public function behaviors()
{
return [
[
'class' => '\years\storage\behaviors\UploadBehavior',
'attributes' => 'avatar',
'disk' => 'qiniu',
'directory' => 'images',
],
];
}
Add validation rule:
public function rules()
{
return [
['avatar', 'file'],
];
}
Setup proper form enctype:
$form = \yii\bootstrap\ActiveForm::begin([
'enableClientValidation' => false,
'options' => [
'enctype' => 'multipart/form-data',
],
]);
File should be uploading fine.
Licence
MIT
All versions of yii2-storage with dependencies
qiniu/php-sdk Version ^7.0
league/flysystem Version ^1.0
yiisoft/yii2 Version ~2.0.5
aliyuncs/oss-sdk-php Version ~2.0
xutl/yii2-collection Version ~1.0.0