class myConfig extends \think\Config
{
public function get($name = null, $default = null){
$ret = parent::get($name);
if ($ret) return $ret;
/// 从api获取配置值,如果为空返回 $default
}
}
希望用 myconfig 替换 config ,使用 Facade 或者 Container 方式,或其他方式。
重点是不改变调用方式: Config::get("mykey")。
对于 laravel 框架,官方文档中有说明。但是 tp 5.1 的文档里,没有相关说明。自己尝试也没有成功,请楼主指点一下。
最佳答案