rmrevin / yii2-file
Yii2 module for file management
Installs: 285
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 5
Forks: 5
Open Issues: 1
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0
- yiisoft/yii2-imagine: ~2.1
README
Code Status
Installation
Add in composer.json
:
{
"require": {
"rmrevin/yii2-file": "~1.1"
}
}
Usage
In config
<? // ... return [ // ... 'modules' => [ // ... 'file' => [ 'class' => '\rmrevin\yii\module\File\Module', 'upload_alias' => '@app/web/upload', 'upload_web_alias' => '/upload', 'storage_alias' => '@app/web/storage', 'storage_web_alias' => '/storage', 'max_upload_file_size' => 10, // megabytes ], ], ];
Save file into database
use rmrevin\yii\module\File; // external resource $File = File\models\File::push(new File\component\ExternalResource('https://www.google.ru/images/srpr/logo11w.png')); // internal resource $File = File\models\File::push(new File\component\InternalResource('/var/www/images/pick.png')); // uploaded resource $File = File\models\File::push(new File\component\UploadedResource(UploadedFile::getInstance($model, 'file')));
Manipulation with images
use rmrevin\yii\module\File; $File = File\models\File::find()->one(); echo Html::img((string)$File->image() ->resizeByWidth(100)); // available methods: resize, resizeByWidth, resizeByHeight, crop, thumbnail, watermark, text