URL大小写
#默认url大小写不敏感
#如果设置了以下值,则url大小写敏感
'url_convert' => false,
隐藏入口文件
#apache重设置
AllowOverride All
#.htaccess
deny from all
修改类库名称
#应用配置文件中
'app_namespace' => 'application',
数据输出格式
#默认输出格式为json,自动将数组转换为json返回
# view xml json jsonp
'default_return_type'=>'json'
配置加载顺序
惯例配置->应用配置->扩展配置->场景配置->模块配置->动态配置
场景配置
'app_status'=>'office'
#自动加载以下配置文件
#application/office.php
返回xml格式数据
#方法中:
return xml(['data'=>$data,'code'=>1,'message'=>'操作完成']);
调试
'app_trace' => true,
'trace' => [
'type' => 'socket',
// socket服务器
'host' => 'slog.thinkphp.cn',
],
读取配置
Config::get();
Config::has()
设置配置参数
Config::set('key','value')
Config::set([
''=>'',
''=>''
])
config([]);
独立配置
需要在config.php中添加以下配置
'extra_config_list' => ['database'],
/* 数据库设置 */
return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'thinkphp',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '',
// 数据库连接端口
'hostport' => '',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => '',
// 数据库调试模式
'debug' => false,
路由模式
#普通模式
'url_route_on' => false,
#混合模式
'url_route_on' => true,
'url_route_must'=> false,
#强制模式
'url_route_on' => true,
'url_route_must' => true,
开启调试模式
app_debug = true
//显示错误信息,关闭调试模式后仍可使用
'show_error_msg' => true,