PHP code example of jakharbek / yii2-filemanager

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

    

jakharbek / yii2-filemanager example snippets


'modules' => [
    'files' => \jakharbek\filemanager\backend\Module::class
],

 [
     'thumbs' => [
         'icon' => [
             'w' => 50,
             'h' => 50,
             'q' => 50,
             'slug' => 'icon'
         ],
         'small' => [
             'w' => 320,
             'h' => 320,
             'q' => 50,
             'slug' => 'small'
         ],
         'low' => [
             'w' => 640,
             'h' => 640,
             'q' => 50,
             'slug' => 'low'
         ],
         'normal' => [
             'w' => 1024,
             'h' => 1024,
             'q' => 50,
             'slug' => 'normal'
         ]
     ],
     'images_ext' => [
         'jpg',
         'png',
         'bmp',
         'gif'
     ],
     'use_file_name' => true,
     'use_queue' => false,
     'file_not_founded' => '14',
     //'file_not_founded' => 'http://img.domain.loc/files/1.jpg'
 
 

'bootstrap' => [
    \jakharbek\filemanager\bootstrap\SetUp::class
],

public function getPostImages()
{
    return $this->hasMany(PostImage::className(), ['post_id' => 'post_id']);
}
 
public function getImages()
{
    return $this->hasMany(Files::className(), ['file_id' => 'file_id'])->viaTable('postImages', ['post_id' => 'post_id']);
}
 

 'file_relation_image' => [
  'class' => FileRelationBehavior::class,
  'delimtr' => ',',
  'attribute' => 'file_image'
 ],
 

 public $file_image
 

 private $_file_image;
  
 public function getFileImage(){
    return $this->$_file_image;
 }
 
 public function setFileImage($value){
    return $this->$_file_image = $value;
 }
 

 public function rules()
 {
    return [ 
            [['file_image'], 'safe']],
     ];
 }
 

 use \jakharbek\filemanager\widgets\FileInput;

use \jakharbek\filemanager\widgets\FileInput;

echo FileInput::widget(['id' => 'post_images_id']);


    echo $form->field($model, 'description')->widget(CKEditor::className(), [
        'options' => ['rows' => 6],
        'clientOptions'=>[
            'extraPlugins' => 'filemanager-jakhar',
            'justifyClasses'=>[ 'AlignLeft', 'AlignCenter', 'AlignRight', 'AlignJustify' ],
            'height'=>200,
            'toolbarGroups' => [
                ['name' => 'filemanager-jakhar']
            ],
        ],
        'preset' => 'short'
    ]);

<?=\jakharbek\filemanager\widgets\FileInput::widget(['id' => 'fileManagerEditor','editor' => true]);

php composer.phar