<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # PSR 7 與值對象(Value Objects) ***** Slim supports[PSR-7](https://github.com/php-fig/http-message)interfaces for its Request and Response objects. This makes Slim flexible because it can use*any*PSR-7 implementation. For example, you could return an instance of`GuzzleHttp\Psr7\CachingStream`or any instance returned by the`GuzzleHttp\Psr7\stream_for()`function. > Slim為其請求和響應對象支持[PSR-7](https://github.com/php-fig/http-message)接口。這使得Slim非常靈活,因為它可以使用任何PSR-7實現。例如,您可以返回 `GuzzleHttp\Psr7\CachingStream` 的實例,或者 `GuzzleHttp\Psr7\stream_for()` 函數返回的任何實例。 Slim provides its own PSR-7 implementation so that it works out of the box. However, you are free to replace Slim’s default PSR-7 objects with a third-party implementation. Just override the application container’s`request`and`response`services so they return an instance of`Psr\Http\Message\ServerRequestInterface`and`Psr\Http\Message\ResponseInterface`, respectively. Slim提供了自己的PSR-7實現,因此可以開箱即用。但是,您可以使用第三方實現替換Slim的默認PSR-7對象。只需覆蓋應用程序容器的`請求`和`響應`服務,以便它們分別返回 `Psr\Http\Message\ServerRequestInterface` 和 `Psr\Http\Message\ResponseInterface` 的實例。 # 值對象 Request and Response objects are[*immutable value objects*](http://en.wikipedia.org/wiki/Value_object). They can be “changed” only by requesting a cloned version that has updated property values. Value objects have a nominal overhead because they must be cloned when their properties are updated. This overhead does not affect performance in any meaningful way. > 請求和響應對象是[*immutable value objects*](http://en.wikipedia.org/wiki/Value_object)。只能通過請求具有更新屬性值的克隆版本來“更改”它們。值對象有名義上的開銷,因為必須在更新其屬性時克隆它們。這種開銷不會以任何有意義的方式影響性能。 You can request a copy of a value object by invoking any of its PSR-7 interface methods (these methods typically have a`with`prefix). For example, a PSR-7 Response object has a`withHeader($name, $value)`method that returns a cloned value object with the new HTTP header. > 您可以通過調用值對象的任何PSR-7接口方法(這些方法通常具有`with` 前綴)來請求值對象的副本。例如,一個PSR-7響應對象有一個 `withHeader($name, $value)` 方法,該方法用新的HTTP頭返回一個克隆的值對象。 ~~~php <?php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require __DIR__ . '/../vendor/autoload.php'; $app = AppFactory::create(); $app->get('/foo', function (Request $request, Response $response, array $args) { $payload = json_encode(['hello' => 'world'], JSON_PRETTY_PRINT); $response->getBody()->write($payload); return $response->withHeader('Content-Type', 'application/json'); }); $app->run(); ~~~ > PSR-7接口提供了這些方法來轉換請求和響應對象: * `withProtocolVersion($version)` * `withHeader($name, $value)` * `withAddedHeader($name, $value)` * `withoutHeader($name)` * `withBody(StreamInterface $body)` > PSR-7接口提供了這些方法來轉換請求對象: * `withMethod($method)` * `withUri(UriInterface $uri, $preserveHost = false)` * `withCookieParams(array $cookies)` * `withQueryParams(array $query)` * `withUploadedFiles(array $uploadedFiles)` * `withParsedBody($data)` * `withAttribute($name, $value)` * `withoutAttribute($name)` > PSR-7接口提供了這些方法來轉換響應對象: * `withStatus($code, $reasonPhrase = '') ` > 有關這些方法的更多信息,請參閱[PSR-7文檔](http://www.php-fig.org/psr/psr-7/)。 [ PSR-7 HTTP 消息接口規范翻譯文檔](https://learnku.com/docs/psr/psr-7-http-message/1616)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看