diff --git a/config/config.php b/config/config.php index 8041cee3..cb1d9b3b 100644 --- a/config/config.php +++ b/config/config.php @@ -21,7 +21,7 @@ return [ 'source' => [ 'extensions' => ['php', 'yaml', 'yml', 'json', 'toml'], // 配置文件扩展名 'paths' => [ - SOURCE_ROOT_DIR . '/config', // 配置文件所在目录 + \ZM\Framework::getInstance()->runtime_preferences->getConfigDir(), // 配置文件所在目录 // 可以添加多个配置文件目录 ], ], diff --git a/src/ZM/Config/RuntimePreferences.php b/src/ZM/Config/RuntimePreferences.php index 458f2377..a1ea4455 100644 --- a/src/ZM/Config/RuntimePreferences.php +++ b/src/ZM/Config/RuntimePreferences.php @@ -56,7 +56,8 @@ class RuntimePreferences public function getConfigDir(): string { - return $this->config_dir; + // fallback to internal config dir if config_dir not exists + return is_dir($this->config_dir) ? $this->config_dir : FRAMEWORK_ROOT_DIR . '/config'; } public function withConfigDir(string $config_dir): self