项目的配置文件位于/config/下
startmvc自带了common(系统配置)、database(数据库配置)、pagination(分页配置)、route(路由配置)。
common配置
common为项目常规配置,默认是自动加载的,在控制器、模型或视图中,可以通过$this->Conf['配置名称']来获取或动态设置配置信息。
return [
'debug' => true, //Debug模式,开发过程中开启,生产环境中请关闭
'timezone' => 'PRC', //系统时区
'url_suffix' => '.html', //URL后缀
'default_module' => 'Home', //默认模块,单模块可以不填
'default_controller' => 'Index', //默认控制器
'default_action' => 'index', //默认方法
'urlrewrite' => true, //是否Url重写,隐藏index.php,需要服务器支持和对应的规则
'session_prefix' => '', //Session前缀
'cookie_prefix' => '', //Cookie前缀
'cache_status'=>true, //false为关闭,true为开启缓存
'cache_type'=>'file', //支持类型 : file [文件型],redis[内存型]
//以下配置内存型redis缓存的必须设置
'cache_host' => '127.0.0.1', //主机地址
'cache_port' => '6379', //端口 redis 一般为 6379
'cache_prefix' => 'sm_' //缓存变量前缀
'locale' => 'zh_cn' //指定默认语言,默认zh_cn简体中文
'db_auto_connect' => true, //是否开启数据库自动连接
];
$isDebug = $this->conf['urlrewrite']; //获取配置信息
$this->conf['urlrewrite'] = false; //设置配置信息
其它配置信息使用时,直接使用include加载配置文件。例如:
$pageconf = include ROOT_PATH . '/config/pagination.php';
echo $pageconf['first']; //输出名称 首页