Yii2 params access within local config file in common directory

前端 未结 3 1728
感情败类
感情败类 2020-12-19 04:27

I\'m using Yii2 advanced template, I want to access params.php in main-local.php file, I called this ways:

main-local.

3条回答
  •  独厮守ぢ
    2020-12-19 05:02

    The params is a part of config and you can not call this in your config .

    the best way for handel this you can use this in your class :

    myClass:

    class myClass extends ... {
    
        public $apikey;
    
        public function __construct(){
            $this->apikey =  \Yii::$app->params['mandrill_api_key'];
        }
    
    
    }
    

提交回复
热议问题