/** * 加载配置 * * @param string $file * @return void */ public function required($file) { $md5 = md5($file); if (isset($this->required[$md5])) { return $this->required[$md5]; } $this->required[$md5] = $this->files->getRequire($file); }
/** * 加载指定的配置文件 * * @param string $environment 环境 * @param string $group 组 * @param string $namespace * @return array */ public function load($environment, $group, $namespace = null) { $items = []; $path = $this->getPath($namespace); if (is_null($path)) { return $items; } // 总是加载默认的配置 $file = "{$path}/{$group}.php"; if ($this->files->exists($file)) { $items = $this->files->getRequire($file); } // 加载指定环境中的配置 $file = "{$path}/{$environment}/{$group}.php"; if ($this->files->exists($file)) { $items = array_merge($items, $this->files->getRequire($file)); } return $items; }