PHP code example of tecsin / yii2-elfinder

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

    

tecsin / yii2-elfinder example snippets


class AdminController extends Controller
{
   
  public function actionUpload(){
     $fileManager = new \tecsin\elfinder\FileManager();
      $fileManager->_uploadPath = Yii::getAlias('@webroot').'/files/';
      $fileManager->_uploadUrl = Yii::getAlias('@web').'/files/';
      /*to mount Google Drive with flysystem starts. OPTIONAL*/
      $fileManager->googleDrive = [
                  'clientID' => 'xxxxxx',
                  'clientSecret' => 'xxxxxxx',
                  'refreshToken' => 'xxxxxx',
                  'useCache' => true //optional
                  ]; 
      /*to mount Google Drive ends*/
      $fileManager->connector();
  }

 /**to use only for file manager for web**/
    public function actionFileManager() {
        return $this->render('file-manager');
    }
  
/**to use only for file browser (picker) for tinymce**/
  public function actionFileBrowser(){
      return $this->renderAjax('file-browser');//use ajax not to have a new site load in the file browser window
  }
  
}

    
    /**
     * @var array clientOptions the options for configuration.
     * @see https://github.com/elfinder/wiki For full list of configurable options.
     */
<?= \tecsin\elfinder\ElFinderWidget::widget([
    'id' => 'working',
    'clientOptions' => [
        'url' => '/admin/upload'
    ]
]); 

<?= \tecsin\elfinder\ElFinderWidget::widget([
    'id' => 'working',
    'useWithTinyMCE' => true,//REQUIRED
    'clientOptions' => [
        'url' => '/admin/upload'
    ]
]); 

php composer.phar