rmrevin/yii2-file Yii2 module for file management

fileupload

Yii 2 module for file management

License Latest Stable Version Latest Unstable Version Total Downloads

Code Status

Scrutinizer Code Quality Code Coverage Travis CI Build Status Dependency 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

Changelog

2015-05-18

  • Classes resources \rmrevin\yii\module\File\component\*Resource transferred to the own namespace rmrevin\yii\module\File\resources\*Resource.
  • Update tests.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.2.5 is the latest of 11 releases



MIT license
Stats
9 github stars & 4 github forks
0 downloads in the last day
0 downloads in the last 30 days
278 total downloads