/** * 通过指定的KEY,优先从ENV文件中读取配置,如果ENV中没有,再去config目录下获取 * * @param string $key 参数KEY(文件名.数组索引[.数组索引...]) * @return mixed 参数值 */ public static function getEnv(string $key = '') { return BaseConfig::getEnv($key); }
/** * 定时任务刷新入口 */ public function task_refresh() { $QpException = new Exception(); try { // 1.加载配置文件 - /config目录下的php文件 Config\BaseConfig::init(['app', 'database', 'session']); Config\BaseConfig::initEnv(); // 2.设置默认时区 - 从配置中读取 date_default_timezone_set(Config::getEnv("app.timezone")); // 3.定义日志目录路径 - 从配置中读取 $this->setLogPath(); // 4.注册命名空间 $this->setNamespace(); // 5.定义Phalcon的DI $di = new \Phalcon\DI\FactoryDefault(); // 6.预加载数据库链接 $this->handleDBConnection($di); // 7.设置Redis数据库连接 $this->handleRedis($di); // 8.处理刷新任务 $this->handleTaskRefresh($di); } catch (\Exception $ex) { Log\SystemLog::error_log($ex); $QpException->fatalHandler($ex); } catch (\Throwable $ex) { Log\SystemLog::error_log($ex); $QpException->fatalHandler($ex); } }
/** * 优先从开发环境中读取配置 * * @param mixed $key 配置项 * @return mixed */ function config(string $key = '') { return \Qp\Kernel\Config\BaseConfig::getEnv($key); }