PHP code example of kr0lik / yii2-resource

1. Go to this page and download the library: Download kr0lik/yii2-resource 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/ */

    

kr0lik / yii2-resource example snippets


use yii\db\ActiveRecord;
use kr0lik\resource\ResourceBehavior;

class YourModel extends ActiveRecord
{
    ...
    public function behaviors()
    {
        return [
            'resource' => [
                'class' => ResourceBehavior::class,
                'attributes' => ['file'],
                'folder' => 'path/to/store/file/folder',
                'tmpFolder' => 'path/to/temp/file/folder'
                'originalFileNameAttribute' => 'attribute to store original file name. if null - no store'
            ]
        ];
    }
    ...
}