PHP code example of rob006 / yii-elfinder2

1. Go to this page and download the library: Download rob006/yii-elfinder2 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/ */

    

rob006 / yii-elfinder2 example snippets


   'aliases' => [
       'elFindervendor' => 'vendor.myCystomElFinder',
   ],
   

   class ElfinderController extends Controller {
   
       // don't forget configure access rules
   
       public function actions() {
           return [
               // main action for elFinder connector
               'connector' => [
                   'class' => 'ext.elFinder.ElFinderConnectorAction',
                   // elFinder connector configuration
                   // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
                   'settings' => [
                       'roots' => [
                           [
                               'driver' => 'LocalFileSystem',
                               'path' => Yii::getPathOfAlias('webroot') . '/files/',
                               'URL' => Yii::app()->baseUrl . '/files/',
                               'alias' => 'Root Alias',
                               'acceptedName' => '/^[^\.].*$/', // disable creating dotfiles
                               'attributes' => [
                                   [
                                       'pattern' => '/\/[.].*$/', // hide dotfiles
                                       'read' => false,
                                       'write' => false,
                                       'hidden' => true,
                                   ],
                               ],
                           ],
                       ],
                   ],
               ],
               // action for TinyMCE popup with elFinder widget
               'elfinderTinyMce' => [
                   'class' => 'ext.elFinder.TinyMceElFinderPopupAction',
                   'connectorRoute' => 'connector', // main connector action id
               ],
               // action for file input popup with elFinder widget
               'elfinderFileInput' => [
                   'class' => 'ext.elFinder.ServerFileInputElFinderPopupAction',
                   'connectorRoute' => 'connector', // main connector action id
               ],
           ];
       }
   }
   

   $this->widget('ext.elFinder.ServerFileInput', [
       'model' => $model,
       'attribute' => 'field_name',
       'popupConnectorRoute' => 'elfinder/elfinderFileInput', // relative route for file input action
       // ability to customize "Browse" button
   //	'customButton' => CHtml::button('Browse images', [
   //		'id' => CHtml::getIdByName(CHtml::activeName($model, 'field_name')) . 'browse',
   //		'class' => 'btn', 'style' => 'margin-left:10px',
   //	]),
       // title for popup window (optional)
       'popupTitle' => 'Files',
   ]);
   

   $this->widget('ext.elFinder.ElFinderWidget', [
       'connectorRoute' => 'elfinder/connector', // relative route for elFinder connector action
   ]);
   

   $this->widget('ext.tinymce.TinyMce', [
       'model' => $model,
       'attribute' => 'content',
       'fileManager' => [
           'class' => 'ext.elFinder.TinyMceElFinder',
           'popupConnectorRoute' => 'elfinder/elfinderTinyMce', // relative route for TinyMCE popup action
           // title for popup window (optional)
           'popupTitle' => 'Files',
       ],
   ]);