学习ThinkPHP3.2.2:video9,对3.1的分组与3.2.2的模块的理解

由于跟视频动手没法进行,根据3.2.2的手册进行调整。

3.1的分组到3.2已经变为模块。视频中的分组配置参数 APP_GROUP_LIST 已经变为无效。


先配置 index.php:

// 定义公共模块路径

define ('COMMON_PATH', './Common/');


然后分别配置了Common、App、Admin目录进行测试:

1、D:\wamp\www\wish\index.php:

// 公共模块

define ('COMMON_PATH', './Common/');


// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false

define('APP_DEBUG',True);


// 定义应用目录

define('APP_PATH','./APP/');


// 引入ThinkPHP入口文件

require './ThinkPHP/ThinkPHP.php';


2、D:\wamp\www\wish\admin.php:

// 公共模块

define ('COMMON_PATH', './Common/');


// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false

define('APP_DEBUG',True);


// 定义应用目录

define('APP_PATH','./Admin/');


// 引入ThinkPHP入口文件

require './ThinkPHP/ThinkPHP.php';


3、D:\wamp\www\wish\Common\Conf\config.php

'CVAR'    => 'this is Common var',


4、D:\wamp\www\wish\Admin\Home\Conf\config.php

'AVAR'  => 'this is Admin var',


5、D:\wamp\www\wish\APP\Home\Conf

'IVAR'  => 'this is Index var',


6、现在有2个模块,index方法都定义为:

echo 'try to read Common config:'.C('CVAR');

echo '<br/>';

echo 'try to read Index config:'.C('IVAR');  

echo '<br/>';

echo 'try to read Admin config:'.C('AVAR'); 


7、浏览 http://localhost/wish/admin.php:

显示:

try to read Common config:this is Common var
try to read Index config:
try to read Admin config:this is Admin var


8、浏览:http://localhost/wish/index.php

显示:

try to read Common config:this is Common var
try to read Index config:this is Index var
try to read Admin config:


由此可以看到,设置的公共参数,两个模块都能读取,模块目录下的参数仅能由本模块读取。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值