Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
1. Title of the call
Set 1.1
<?php
return [
'title' => '图书商城',
"domain" => [
'www' => 'http://super.nat300.top/',
'm' => 'http://super.nat300.top/m',
'web' => 'http://super.nat300.top/web',
'weixin' => 'http://super.nat300.top/weixin',
],
"upload" => [
'avatar' => "/uploads/avatar",
'brand' => "/uploads/brand",
'book' => "/uploads/book",
],
"weixin" => [
"appid" => 'wxc01ba9b834be5023',
"sk" => 'da1e24dd41859f769b23c089f827268c',
"token" => 'tomalang689',
"aeskey" => 'P6PaB6bPrRzKkva5lq6kHWtYkOOlVhYq4fh1iR7LMKB',
'pay' => [
'key' => '',
'mch_id' => '',
'notify_url' => [
'm' => '/pay/callback'
]
]
]
];
1.2 calls
<title><?=Yii::$app->params['title'];?></title>
2.URL patchwork
Set 2.1
<?php
return [
'title' => '编程商城',
'domain' => [
'www' => 'http://book_my.aa.test',
'm' => 'http://book_my.aa.test/m',
'web' => 'http://book_my.aa.test/web'
],
2.2 calls
public static function buildMUrl( $path,$params = [] ){
$domain_config = \Yii::$app->params['domain'];
$path = Url::toRoute(array_merge([ $path ],$params));
return $domain_config['m'] .$path;
}
3. Load order
后面的会覆盖前面的
1、common/config/params.php
2、common/config/params-local.php
3、frontend/config/params.php
4、frontend/config/params-local.php
4. page parameters
Step 1 4.1
//先获取当前View,然后给view设置参数
class TestController extends Controller
{
public function actionIndex()
{
//给当前view设置params参数
//在任何地方都可以通过表达式 Yii::$app->view 访问 view 应用组件
$view = Yii::$app->view->params['data'] = '这是要传递的数据';
return $this->render('index');
}
}
进行设置的params参数
Yii::$app->view->params['current_user'] = $member_info;
4.2 Step 2
<?php echo $this->params['data']?> //输出:这是要传递的数据
5. Reference
https://blog.csdn.net/LX_96/article/details/52126627