thinkphp5自定义扩展配置文件并读取后台配置数据
发布时间:2019-03-07作者:豆子点击:179
5.0.1
开始增加了扩展配置目录的概念,在应用配置目录或者模块配置目录下面增加extra
子目录,下面的配置文件都会自动加载,无需任何配置。public function update() { $configfile=__DIR__ . '/../../../application/extra/sysconfig.php'; $file=include $configfile; $config=[ 'sys_basehost'=>input('sys_basehost'), 'sys_webname'=>input('sys_webname'), ]; $res=array_merge($file,$config); $str='<?php return ['; foreach ($res as $key => $value) { $str .='\''.$key.'\''.'=>'.'\''.$value.'\''.','; }; $str .='];'; if(file_put_contents($configfile, $str)){ $this->success("配置成功","sytem/index"); }else { $this->error("配置失败!"); } }