[TOC]
## 配置數據
> 1. /config/config.php
~~~
return [
'oss' => [
'buket' => 'test'
]
]
~~~
> 2. /config/autoload/oss.php
~~~
return [
'buket' => 'test'
]
~~~
## 獲取數據
### 注入Config對象方式
~~~
class IndexController
{
/**
* @Inject
* @var \Hyperf\Contract\ConfigInterface
*/
private $config;
public function index()
{
return $this->config->get('oss.buket', 'test');
}
}
~~~
### @Value 注解方式
~~~
class IndexController
{
/**
* @Value("oss.buket")
*/
private $configValue;
public function index() {
return $this->configValue;
}
}
~~~
### config() 函數
> 可以通過`config(string $key, $default)`函數獲取對應的配置
~~~
$buket = config("oss.buket", 'test');
~~~