dongningce9075
2015-10-19 12:24
浏览 48
已采纳

为foreach()yii-app-basic提供的参数无效

I've one module -> users.

->modules
    ->users
        ->controllers
        ->models
        ->views
        ->Users.php

I created one 'config.php' inside 'config' folder of 'users' modules.

->modules
    ->users
        ->config
            ->config.php
        ->controllers
            -> List of Controllers
        ->models
            -> List of models
        ->views
            -> List of Views
        ->Users.php

And, i gave directory path of config.php in init() method of Users.php, as

modules/users/Users.php

<?php

namespace app\modules\users;

class Users extends \yii\base\Module
{
    public $controllerNamespace = 'app\modules\users\controllers';
    public $commonModel = 'app\modules\users\models\Users';

    public function init()
    {
        parent::init();
        \Yii::configure($this,require(__DIR__.'/config/config.php'));
    }
}

But, it is giving error like

PHP Warning – yii\base\ErrorException
"Invalid argument supplied for foreach()".

Screenshot

enter image description here enter image description here enter image description here enter image description here

I am taking reference from Yii2.0 Guide to include a path inside init() method.

Please help me to rectify this issue.

Thanks.

3条回答 默认 最新

相关推荐 更多相似问题