### 為什么要單獨創建一個Request
禁止使用`$_SERVER`,因為這個管理不了。
在 `swoole (雖然有)` `phpunit (cli模式)` 運行怎么辦? 可是沒有 `$_SERVER` `$_POST` .... 等超全局變量的。
(`swoole` 有`$_SERVER` ,但是更加禁止使用)
單獨創建的原因: 可以管理
## 編輯composer.json
添加映射
```
"core\\": "core/"
```

是不是多此一舉? `composer` 自動加載并不會識別 `core`是那個目錄。
`tp5`的

## 關于違背psr規范
`request` 輪子 `應該` 遵守[# PSR-7 HTTP 消息接口規范](https://learnku.com/docs/psr/psr-7-http-message/1616)
你可以在這里看到 `psr-7` 的代碼: https://github.com/php-fig/http-message
違背原因: 太多方法了,我是不會實現這些接口的,因為對于教程,會增加非常多的代碼。
## 創建core/request/RequestInterface.php
```
<?php
namespace core\request;
interface RequestInterface
{
public function __construct($uri, $method, $headers); // 初始化
public static function create($uri, $method, $headers); // 創建request對象
public function getUri(); // 獲取請求url
public function getMethod(); // 獲取請求方法
public function getHeader(); // 獲取請求頭
}
```
## 創建 core/request/PhpRequest.php
```
<?php
namespace core\request;
class PhpRequest implements RequestInterface
{
protected $url;
protected $method;
protected $headers;
public function __construct($uri,$method,$headers)
{
$this->uri = $uri;
$this->method = $method;
$this->headers = $headers;
}
// 創建一個請求
public static function create($uri,$method,$headers = [])
{
return new static($uri, $method, $headers); // new 自己
}
public function getUri()
{
return $this->uri;
}
public function getMethod()
{
return $this->method;
}
public function getHeader()
{
}
}
```
### 運行


- 前言
- 基礎篇
- 1. 第一步 創建框架目錄結構
- 2. 引入composer自動加載
- 3. php自動加載 (解釋篇)
- 4. 創建容器 注冊樹模式
- 5. 關于psr規范解釋
- 6. 關于"容器" "契約" "依賴注入" (解釋篇)
- 7. 添加函數文件helpers.php
- 8. 初始化請求(Request)
- 9. 響應 (Response)
- 10. 路由一 (路由組實現)
- 11. 路由二 (加入中間件)
- 12. 配置信息 (類似laravel)
- 13. 數據庫連接 (多例模式)
- 14. 查詢構造器 (query builder)
- MVC實現
- M 模型實現 (數據映射 + 原型 模式)
- C 控制器實現 + 控制器中間件
- V 視圖實現 (Laravel Blade 引擎)
- V 視圖切換成 ThinkPhp 模板 引擎)
- 其他輪子
- 日志
- 自定義異常 (異常托管)
- 單元測試 (phpunit)
- 替換成swoole的http服務器
- 協程上下文解決request問題
- qps測試
- 發布到packagist.org