配置文件的加载顺序和位置

一共以下几种配置形式,根据顺序越往下优先级越高:

默认配置:ThinkPHP/Conf/convention.php

公共配置;Application/Common/Conf/config.php

模式配置:Application/Common/Conf/config_模式名称.php

调试配置:Application/Common/Conf/debug.php

场景配置:在Application/Common/Conf/场景名称.php     (需要在入口文件中生命,例如 : define('APP_STATUS','home');)

模块配置:默认情况下在Application/模块名称(例如home)/Conf/config.php

扩展配置:这是一种特殊情况的配置,配置文件单独写需要引入到其他配置文件中去应用。

例如在ApplicationHomeConf下新建admin_user.php

<?php

return array(
	array(
		'id'=>1,
		'username'=>'root',
		'password'=>'root'
	),
	array(
		'id'=>'2',
		'username'=>'admin',
		'password'=>'admin'
	)
);

  然后如果要用这个配置文件的内容就要在同等级的配置文件config.php中利用函数引入

<?php
return array(
	//'配置项'=>'配置值'
	'LOAD_EXT_CONFIG'=>array('ADMIN'=>'admin_user')
);

  这样就可以了,就将扩展配置文件中的配置内容赋值给了ADMIN了。

动态配置:就是利用配置文件操作函数C函数,直接写入。

原文地址:https://www.cnblogs.com/DamonBlog/p/10381341.html