Yii 2.0: yii2-roxymce

RoxyMce - Beautiful File manager for Tinymce

RoxyMce - Beautiful File manager for Tinymce

This allow to integrate TinyMce 4 with Roxy File Manager


Preferred way to install this extension through composer
Either run

composer require navatech/yii2-roxymce "^2.0"

Or add to require section of composer.json then run composer update

"navatech/yii2-roxymce" : "^2.0" 

Configure & Usage

Configure module


  • uploadFolder the directory where stored file. Default is @app/web/uploads/images. If folder not existed, roxy will auto-create it.
  • defaultView display type. Default is thumb
  • dateFormat Datetime format. Default is Y-m-d H:i. See: http://php.net/manual/en/function.date.php
  • rememberLastFolder would you want to remember last folder? Default is true
  • rememberLastOrder would you want to remember last order? Default is true
  • allowExtension allowed files extension. Default is jpeg jpg png gif mov mp3 mp4 avi wmv flv mpeg webm


Add to config file: 'modules' => [ 'roxymce' => [ 'class' => 'navatech\roxymce\Module', 'uploadFolder' => '@frontend/web/uploads/images', ], ],

Widget Usage


  • model Instance of Model|ActiveRecord. Required if name has not been defined.
  • attribute attribute name in your model. Required if name has not been defined & when model has been defined.
  • name input's name. Required if model & attribute has not been defined.
  • value default value of tinymce. Not required Default is value of $model->$attribute or empty when not using model section
  • action default is Url::to(['/roxymce/default/index']) Not required
  • options default options of textarea. Not required. See: Html::textarea()
  • clientOptions Tinymce options. Not required. See: https://www.tinymce.com/docs/
    • title Title bar of roxymce iframe. Not required


In your view file, call roxymce widget

Include ActiveRecord Model

echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
    'model'     => app\models\Post::findOne(1),
    'attribute' => 'content',

Sample HTML without ActiveRecord Model

echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
    'name' => 'Post[content]'




Bugs & Issues

Found some bugs? Just create an issue or fork it and send pull request

Total 8 comments

#19958 report it
clauer at 2016/10/12 10:26am
Need help please, bug?


there seems to be a bug in both Module.php and RoxyHelpers.php which prevents from getting the right base directory for uploaded files.

Modules.php line 85:

replace $FilesRoot = RoxyHelper::fixPath(RoxyHelper::getBasePath() . RoxyHelper::getFilesPath());

with $FilesRoot = RoxyHelper::fixPath(RoxyHelper::getFilesPath());

RoxyHelpers.php static function getFilesPath() line 204

replace $ret = FileHelper::fixPath(RoxyHelper::getBasePath() . Yii::getAlias('@web/') . FILES_ROOT);

with $ret = FileHelper::fixPath(Yii::getAlias('@web/') . FILES_ROOT);

otherwise the basePath or @web would be doubled.

Regards Christian

#19957 report it
clauer at 2016/10/12 07:13am
Need help please

Hi, I just installed navatech roxymce sucessfully with composer in yii2 advanced app.

Directory structure of the site (absolute paths): Application: www/htdocs/user/test/yii-adv Web root: www/htdocs/user/test/yii-adv/backend/web Files folder: www/htdocs/user/test/yii-adv/files

How to configure the param FILES_ROOT in config that it points to the files folder? With every value I set, even the absolute path, a new folder is created which looks like www/htdocs/user/test/yii-adv/www/htdocs/user/test/yii-adv/...

Would appreciate any help even directly to post@netzw.de, thanks! Christian

#19808 report it
TuoiTeen at 2016/03/19 12:41am
Field "attribute" is required

look like you use RoxyWidget with model ActiveRecord, so you missing field "attribute"

echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
    'model'       => $model, //your Model, REQUIRED
    'attribute' => 'content', //attribute name of your model, REQUIRED if using 'model' section
#19807 report it
clauer at 2016/03/18 05:13pm
Content of my email


Thanks for your quick answer.

Seems the error has another reason. Below you may find the stack after calling roxymcewidget, the entry in config/web.php, the content of the folder below vendor and the source of the model StaticContent. The stack reports that an attribute is missing but I don't know exactly which one.

Regards Christian Lauer


1. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\widgets\RoxyMceWidget.php at line 55

     * This method is invoked at the end of the constructor after the object is initialized with the
     * given configuration.
     * @throws InvalidParamException
    public function init() {
        if ($this->model !== null) {
            if ($this->attribute === null) {
                throw new InvalidParamException('Field "attribute" is required');
            } else {
                $model = $this->model;
                if (method_exists($model, 'hasAttribute') && $model->hasAttribute($this->attribute)) {
                    $this->id = $model::tableName() . '_' . $this->attribute;
                } else {
                    throw new InvalidParamException('Column "' . $this->attribute . '" not found in model');
        } else {

2. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\Object.php at line 107 – navatech\roxymce\widgets\RoxyMceWidget::init()
3. yii\base\Object::__construct(['model' => app\models\StaticContent])
4. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\di\Container.php at line 374 – ReflectionClass::newInstanceArgs([['model' => app\models\StaticContent]])
5. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\di\Container.php at line 153 – yii\di\Container::build('navatech\roxymce\widgets\RoxyMce...', [], ['model' => app\models\StaticContent])
6. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\BaseYii.php at line 344 – yii\di\Container::get('navatech\roxymce\widgets\RoxyMce...', [], ['model' => app\models\StaticContent])
7. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\Widget.php at line 97 – yii\BaseYii::createObject(['model' => app\models\StaticContent, 'class' => 'navatech\roxymce\widgets\RoxyMce...'])
8. in D:\Web\htdocs\wsk\wsk\test\unserCMS\views\static-content\_form.php at line 15 – yii\base\Widget::widget(['model' => app\models\StaticContent])

/* @var $form yii\widgets\ActiveForm */

echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
    'model' => $model,

<div class="static-content-form">

    <?php $form = ActiveForm::begin(); ?>

9. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 325 – require('D:\Web\htdocs\wsk\wsk\test\unser...')
10. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 247 – yii\base\View::renderPhpFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent])
11. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 149 – yii\base\View::renderFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent], null)
12. in D:\Web\htdocs\wsk\wsk\test\unserCMS\views\static-content\create.php at line 19 – yii\base\View::render('_form', ['model' => app\models\StaticContent])

<div class="static-content-create">

    <h1><?= Html::encode($this->title) ?></h1>

    <?= $this->render('_form', [
        'model' => $model,
    ]) ?>


13. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 325 – require('D:\Web\htdocs\wsk\wsk\test\unser...')
14. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 247 – yii\base\View::renderPhpFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent])
15. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 149 – yii\base\View::renderFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent], app\controllers\StaticContentController)
16. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\Controller.php at line 377 – yii\base\View::render('create', ['model' => app\models\StaticContent], app\controllers\StaticContentController)
17. in D:\Web\htdocs\wsk\wsk\test\unserCMS\controllers\StaticContentController.php at line 82 – yii\base\Controller::render('create', ['model' => app\models\StaticContent])

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,

     * Updates an existing StaticContent model.
     * If update is successful, the browser will be redirected to the 'view' page.

18. app\controllers\StaticContentController::actionCreate()

config/web.php - within modules:

'roxymce'  => [
  'class' => '\navatech\roxymce\Module',

Content of the Folder in the vendor folder

T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech             DIR
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets             DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\css             DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\css\images              DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images              DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images\filetypes                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images\filetypes\big                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\js              DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\lang                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\controllers                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\helpers                DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\views              DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\views\default              DIR 
T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\widgets                DIR 

Source of StaticContent.php (model)


namespace app\models;

use Yii;
use yii\db\ActiveRecord;

 * This is the model class for table "static_content".
 * @property integer $id
 * @property integer $linked
 * @property string $headline
 * @property string $menu_entry
 * @property string $author
 * @property string $creation_date
 * @property string $last_change
 * @property string $text
 * @property string $images
 * @property string $links_int
 * @property string $links_ext
 * @property string $downloads
class StaticContent extends ActiveRecord
     * @inheritdoc
    public static function tableName()
        return '{{%static_content}}';

     * @inheritdoc
    public function rules()
        return [
            [['linked'], 'integer'],
            [['headline', 'text', 'images', 'links_int', 'links_ext', 'downloads'], 'required'],
            [['headline', 'text', 'images', 'links_int', 'links_ext', 'downloads'], 'string'],
            [['creation_date', 'last_change'], 'safe'],
            [['menu_entry', 'author'], 'string', 'max' => 30]

     * @inheritdoc
    public function attributeLabels()
        return [
            'id' => Yii::t('app', 'ID'),
            'linked' => Yii::t('app', 'Linked'),
            'headline' => Yii::t('app', 'Headline'),
            'menu_entry' => Yii::t('app', 'Menu Entry'),
            'author' => Yii::t('app', 'Author'),
            'creation_date' => Yii::t('app', 'Creation Date'),
            'last_change' => Yii::t('app', 'Last Change'),
            'text' => Yii::t('app', 'Text'),
            'images' => Yii::t('app', 'Images'),
            'links_int' => Yii::t('app', 'Links Int'),
            'links_ext' => Yii::t('app', 'Links Ext'),
            'downloads' => Yii::t('app', 'Downloads'),

     * @inheritdoc
     * @return StaticContentQuery the active query used by this AR class.
    public static function find()
        return new StaticContentQuery(get_called_class());
#19804 report it
TuoiTeen at 2016/03/15 11:07pm
no email received

@clauer I just check my inbox at info@navatech.vn, and no email from you there. Can you push it to pastebin.com and post here?

#19803 report it
clauer at 2016/03/15 11:28am


I did send you the composer.lock and two other files describing the issue in detail by email in return to your email.

Thanks for helping

#19802 report it
TuoiTeen at 2016/03/14 03:38pm
maybe composer install failed

Could you please send to me composer.lock?
or make sure:
- run composer in root folder of yii2, not "web" folder
- run "@dev" when "type" section has been removed, and "minimum-stability" has been set to "dev" in composer.json
- folder "navatech/yii2-roxymce" existed on "vendor"
- 'navatech\roxymce\' was loaded to "array($vendorDir . '/navatech/yii2-roxymce/src')" in "vendor/composer/autoload_psr4.php"

Thanks for using.

#19801 report it
clauer at 2016/03/14 01:41pm
Looking for help

I installed the extension as described above, simple config ind web.php and calling roxymce widget in the create / update view file.

The extension is installed by composer.

When calling the view I get a "Class 'navatech\roxymce\widgets\RoxyMceWidget' not found" error.

Here is the code:

    $this->title = Yii::t('app', 'Create Static Content');
    $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Static Contents'), 'url'  => ['index']];
    $this->params['breadcrumbs'][] = $this->title;
    <div class="static-content-create">
        <h1><?= Html::encode($this->title) ?></h1>
        echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
            'model'       => $model,
        <?= $this->render('_form', [
            'model' => $model,
        ]) ?>

Would appreciate any help even directly to post@netzw.de, thanks.

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet