Yii Framework Forum: Yii2 Gii Crud Error Class 'app\models\yii' Not Found - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii2 Gii Crud Error Class 'app\models\yii' Not Found

#1 User is offline   Hashie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 20-February 14

Posted 24 March 2014 - 04:44 AM

I just installed yii2 advanced template, I created a model News and now I want to create the Crud (with gii), but when I click 'preview' I get this error.
I did not change anything else in the advanced template.
I'm using wamp

PHP Fatal Error – yii\base\ErrorException
Class 'app\models\Yii' not found

    1. in C:\wamp\www\advanced\backend\models\News.php at line 44
    2. in C:\wamp\www\advanced\vendor\yiisoft\yii2-gii\generators\crud\default\search.php – yii\gii\generators\crud\Generator::generateSearchLabels() at line 18
    1314151617181920212223

    $searchModelClass = StringHelper::basename($generator->searchModelClass);
    if ($modelClass === $searchModelClass) {
        $modelAlias = $modelClass . 'Model';
    }
    $rules = $generator->generateSearchRules();
    $labels = $generator->generateSearchLabels();
    $searchAttributes = $generator->getSearchAttributes();
    $searchConditions = $generator->generateSearchConditions();

    echo "<?php\n";
    ?>

    3. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\View.php – unknown() at line 312
    4. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderPhpFile() at line 244
    5. in C:\wamp\www\advanced\vendor\yiisoft\yii2-gii\Generator.php – yii\base\View::renderFile() at line 315
    310311312313314315316317318319320

        public function render($template, $params = [])
        {
            $view = new View;
            $params['generator'] = $this;

            return $view->renderFile($this->getTemplatePath() . '/' . $template, $params, $this);
        }

        /**
         * Validates the template selection.
         * This method validates whether the user selects an existing template

    6. in C:\wamp\www\advanced\vendor\yiisoft\yii2-gii\generators\crud\Generator.php – yii\gii\Generator::render() at line 166
    161162163164165166167168169170171

        {
            $controllerFile = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php');
            $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php'));
            $files = [
                new CodeFile($controllerFile, $this->render('controller.php')),
                new CodeFile($searchModel, $this->render('search.php')),
            ];

            $viewPath = $this->getViewPath();
            $templatePath = $this->getTemplatePath() . '/views';
            foreach (scandir($templatePath) as $file) {

    7. in C:\wamp\www\advanced\vendor\yiisoft\yii2-gii\controllers\DefaultController.php – yii\gii\generators\crud\Generator::generate() at line 44
    3940414243444546474849

            $generator = $this->loadGenerator($id);
            $params = ['generator' => $generator, 'id' => $id];
            if (isset($_POST['preview']) || isset($_POST['generate'])) {
                if ($generator->validate()) {
                    $generator->saveStickyAttributes();
                    $files = $generator->generate();
                    if (isset($_POST['generate']) && !empty($_POST['answers'])) {
                        $params['hasError'] = $generator->save($files, (array) $_POST['answers'], $results);
                        $params['results'] = $results;
                    } else {
                        $params['files'] = $files;

    8. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\InlineAction.php – yii\gii\controllers\DefaultController::actionView() at line 54
    9. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\InlineAction.php – call_user_func_array() at line 54
    10. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Controller.php – yii\base\InlineAction::runWithParams() at line 127
    11. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Module.php – yii\base\Controller::runAction() at line 435
    12. in C:\wamp\www\advanced\vendor\yiisoft\yii2\web\Application.php – yii\base\Module::runAction() at line 84
    13. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Application.php – yii\web\Application::handleRequest() at line 312
    14. in C:\wamp\www\advanced\backend\web\index.php – yii\base\Application::run() at line 17
    121314151617

        require(__DIR__ . '/../config/main.php'),
        require(__DIR__ . '/../config/main-local.php')
    );

    $application = new yii\web\Application($config);
    $application->run();

0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 24 March 2014 - 07:28 AM

Fixed. Thanks!
0

#3 User is offline   Hashie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 20-February 14

Posted 24 March 2014 - 07:55 AM

great, I get multiple errors, do I have to post them all?
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,901
  • Joined: 04-October 08
  • Location:DC, USA

Posted 24 March 2014 - 09:53 AM

If you still have issues, you may post them in github issue tracker. Thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users