zxbodya / yii2-gallery-manager

93 stars 61 forks source link

Error Class yii\jui\JuiAsset does not exist #9

Closed raditzlawliet closed 9 years ago

raditzlawliet commented 9 years ago

Hello, i'm trying to use your plugins in yii2. trying same as in readme.md when im trying to open Model/Update?id=1 I got error in while trying to echo widget GalleryManager. (Note im using yii2-advance-template)

ReflectionException Class yii\jui\JuiAsset does not exist

here the details of my script.

frontend/config/main.php & backend/config.main.php

    'modules' => [
        'yii2images' => [
            'class' => 'rico\yii2images\Module',
            //be sure, that permissions ok 
            //if you cant avoid permission errors you have to create "images" folder in web root manually and set 777 permissions
            'imagesStorePath' => 'images/store', //path to origin images
            'imagesCachePath' => 'images/cache', //path to resized copies
            'graphicsLibrary' => 'GD', //but really its better to use 'Imagick' 
            'placeHolderPath' => '@webroot/images/placeHolder.png', // if you want to get placeholder when image not exists, string will be processed by Yii::getAlias
        ],
    ],

composer.json

"require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": "*",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "yiisoft/yii2-gii": "*",
    "yiisoft/yii2-jui": "*",
    "costa-rico/yii2-images": "dev-master",
    "2amigos/yii2-file-input-widget":"~1.0",
    "zxbodya/yii2-gallery-manager": "*@dev"
},

also do composer install

_form.php

use zxbodya\yii2\galleryManager\GalleryManager;

if ($model->isNewRecord) {
    echo 'Can not upload images for new record';
} else {
    echo GalleryManager::widget(
        [
            'model' => $model,
            'behaviorName' => 'galleryBehavior',
            'apiRoute' => 'toilet/galleryApi'
        ]
    );
}

Toilet.php

use zxbodya\yii2\galleryManager\GalleryBehavior;

public function behaviors()
{
    return ArrayHelper::merge(parent::behaviors(), [
        'galleryBehavior' => [
             'class' => GalleryBehavior::className(),
             'type' => 'toilet',
             'extension' => 'jpg',
             'directory' => Yii::getAlias('@webroot') . '/images/toilet/gallery',
             'url' => Yii::getAlias('@web') . '/images/toilet/gallery',
             'versions' => [
                 'small' => function ($img) {
                     /** @var ImageInterface $img */
                     return $img
                         ->copy()
                         ->thumbnail(new Box(200, 200));
                 },
                 'medium' => function ($img) {
                     /** @var ImageInterface $img */
                     $dstSize = $img->getSize();
                     $maxWidth = 800;
                     if ($dstSize->getWidth() > $maxWidth) {
                         $dstSize = $dstSize->widen($maxWidth);
                     }
                     return $img
                         ->copy()
                         ->resize($dstSize);
                 },
             ]
         ]
    ]);
}

ToiletController.php

use zxbodya\yii2\galleryManager\GalleryManagerAction;

public function actions()
{
    return [
       'galleryApi' => [
           'class' => GalleryManagerAction::className(),
           // mappings between type names and model classes (should be the same as in behaviour)
           'types' => [
               'toilet' => Toilet::className()
           ]
       ],
    ];
}

also already done with migrate new Table gallery_image. (is there any column data of my Model must added too ?) thank you.

zxbodya commented 9 years ago

It looks like yiisoft/yii2-juiis not installed, have you tried composer update instead of composer install?(install is not installing new dependencies, only fixed in composer.lock)

Also you have not changed some properties while copy-pasting examples. Likely it is not about error you have, but anyway:

also already done with migrate new Table gallery_image. (is there any column data of my Model must added too ?)

no, gallery would be identified by type from behavior, and primary key from model

raditzlawliet commented 9 years ago

I have tried composer update too. But still same problem. have I miss something ? *Trying to repeat again... install... then update... again and again.

here my composer.json

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Application Template",
    "keywords": ["yii2", "framework", "advanced", "application template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-jui": "*",
        "zxbodya/yii2-gallery-manager": "*"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

I Have change "minimum-stability" from "stable", to "dev".

Thanks for your correction my code, I'm already change 'apiRoute' and 'type' too.

And, here the Stack Trace,

exception 'ReflectionException' with message 'Class yii\jui\JuiAsset does not exist' in E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\di\Container.php:415
Stack trace:
#0 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\di\Container.php(415): ReflectionClass->__construct('yii\\jui\\JuiAsse...')
#1 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\di\Container.php(358): yii\di\Container->getDependencies('yii\\jui\\JuiAsse...')
#2 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Container->build('yii\\jui\\JuiAsse...', Array, Array)
#3 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('yii\\jui\\JuiAsse...', Array, Array)
#4 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\AssetManager.php(228): yii\BaseYii::createObject(Array)
#5 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\AssetManager.php(201): yii\web\AssetManager->loadBundle('yii\\jui\\JuiAsse...', Array, true)
#6 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\View.php(284): yii\web\AssetManager->getBundle('yii\\jui\\JuiAsse...')
#7 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\View.php(289): yii\web\View->registerAssetBundle('yii\\jui\\JuiAsse...', NULL)
#8 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\AssetBundle.php(118): yii\web\View->registerAssetBundle('zxbodya\\yii2\\ga...')
#9 E:\xampp\htdocs\web\advanced\vendor\zxbodya\yii2-gallery-manager\GalleryManager.php(93): yii\web\AssetBundle::register(Object(yii\web\View))
#10 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\Widget.php(97): zxbodya\yii2\galleryManager\GalleryManager->run()
#11 E:\xampp\htdocs\web\advanced\frontend\views\toilet\_form.php(39): yii\base\Widget::widget(Array)
#12 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(325): require('E:\\xampp\\htdocs...')
#13 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(247): yii\base\View->renderPhpFile('E:\\xampp\\htdocs...', Array)
#14 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(149): yii\base\View->renderFile('E:\\xampp\\htdocs...', Array, NULL)
#15 E:\xampp\htdocs\web\advanced\frontend\views\toilet\update.php(19): yii\base\View->render('_form', Array)
#16 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(325): require('E:\\xampp\\htdocs...')
#17 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(247): yii\base\View->renderPhpFile('E:\\xampp\\htdocs...', Array)
#18 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\View.php(149): yii\base\View->renderFile('E:\\xampp\\htdocs...', Array, Object(frontend\controllers\ToiletController))
#19 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\Controller.php(371): yii\base\View->render('update', Array, Object(frontend\controllers\ToiletController))
#20 E:\xampp\htdocs\web\advanced\frontend\controllers\ToiletController.php(115): yii\base\Controller->render('update', Array)
#21 [internal function]: frontend\controllers\ToiletController->actionUpdate('2')
#22 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#23 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#24 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('update', Array)
#25 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('toilet/update', Array)
#26 E:\xampp\htdocs\web\advanced\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#27 E:\xampp\htdocs\web\advanced\frontend\web\index.php(18): yii\base\Application->run()
#28 {main}

Btw, i tried to search file vendor\yiisoft\yii2-jui\JuiAsset.php but it didn't found ? is my composer failed to update fetch the file ?

raditzlawliet commented 9 years ago

Okeh, first problem solve. it's problem in composer it self or ... ? (Maybe I forgot to read all requirement or ?... miss the documentation.)

first yiisoft/yii2-jui stuck at 2.0.0-beta version and I can't update it to 2.0.3. Therefore JuiAsset.php isn't available. Force update to 2.0.3 make some error

  Problem 1
    - Installation request for yiisoft/yii2-jui 2.0.3 -> satisfiable by yiisoft/
yii2-jui[2.0.3].
    - yiisoft/yii2-jui 2.0.3 requires bower-asset/jquery-ui 1.11.*@stable -> no
matching package found.
  Problem 2
    - zxbodya/yii2-gallery-manager dev-master requires yiisoft/yii2-jui * -> sat
isfiable by yiisoft/yii2-jui[2.0.3, dev-master, 2.0.x-dev, dev-normalize-languag
e-for-asset].
    - zxbodya/yii2-gallery-manager dev-master requires yiisoft/yii2-jui * -> sat
isfiable by yiisoft/yii2-jui[2.0.3, dev-master, 2.0.x-dev, dev-normalize-languag
e-for-asset].
    - yiisoft/yii2-jui dev-normalize-language-for-asset requires bower-asset/jqu
ery-ui 1.11.*@stable -> no matching package found.
    - yiisoft/yii2-jui 2.0.x-dev requires bower-asset/jquery-ui 1.11.*@stable ->
 no matching package found.
    - yiisoft/yii2-jui dev-master requires bower-asset/jquery-ui 1.11.*@stable -
> no matching package found.
    - yiisoft/yii2-jui 2.0.3 requires bower-asset/jquery-ui 1.11.*@stable -> no
matching package found.
    - Installation request for zxbodya/yii2-gallery-manager *@dev -> satisfiable
 by zxbodya/yii2-gallery-manager[dev-master].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your min
imum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.

i found solution on yii forum, just doing composer global require "fxp/composer-asset-plugin:1.0.0" then do composer update again.

it will update the yiisoft/yii2-jui to 2.0.3 and other component as well.

Thank you. Time to try now :+1: