load(); self::$app_config = $app_config; self::$config_path = $config_path; } /** * @use 写入配置 * @param $key * @param $val * @return bool */ private static function _put($key, $val) { if (!is_null($val)) { if (!empty(self::$config_path)) { file_put_contents(self::$config_path, preg_replace( '/^' . $key . '=\S*/m', $key . '=' . $val, file_get_contents(self::$config_path) )); } } putenv($key . '=' . $val); // self::$app_config->load(); return true; } /** * @use 读出配置 * @param string|null $key * @return mixed|null */ private static function _get($key) { if (self::$app_config->required($key)) { return getenv($key); } return null; } }