當前位置: 首頁>>代碼示例>>PHP>>正文


PHP App::respond方法代碼示例

本文整理匯總了PHP中Slim\App::respond方法的典型用法代碼示例。如果您正苦於以下問題:PHP App::respond方法的具體用法?PHP App::respond怎麽用?PHP App::respond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slim\App的用法示例。


在下文中一共展示了App::respond方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderResponse

 /**
  * @param ResponseInterface $response
  */
 private function renderResponse(ResponseInterface $response)
 {
     if ($this->slim) {
         $this->slim->respond($response);
     } else {
         // do something
     }
 }
開發者ID:quickenloans-mcp,項目名稱:mcp-panthor,代碼行數:11,代碼來源:SlimRenderingTrait.php

示例2: testRespondNoContent

 /**
  * @runInSeparateProcess
  */
 public function testRespondNoContent()
 {
     $app = new App();
     $app->get('/foo', function ($req, $res) {
         $res = $res->withStatus(204);
         return $res;
     });
     // Prepare request and response objects
     $env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo', 'REQUEST_METHOD' => 'GET']);
     $uri = Uri::createFromEnvironment($env);
     $headers = Headers::createFromEnvironment($env);
     $cookies = [];
     $serverParams = $env->all();
     $body = new Body(fopen('php://temp', 'r+'));
     $req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $res = new Response();
     // Invoke app
     $resOut = $app($req, $res);
     $app->respond($resOut);
     $this->assertInstanceOf('\\Psr\\Http\\Message\\ResponseInterface', $resOut);
     $this->assertEquals([], $resOut->getHeader('Content-Type'));
     $this->assertEquals([], $resOut->getHeader('Content-Length'));
     $this->expectOutputString('');
 }
開發者ID:javenlalla,項目名稱:slim-temp,代碼行數:27,代碼來源:AppTest.php

示例3: testRespondWithPaddedStreamFilterOutput

 /**
  * @runInSeparateProcess
  */
 public function testRespondWithPaddedStreamFilterOutput()
 {
     $availableFilter = stream_get_filters();
     if (in_array('mcrypt.*', $availableFilter) && in_array('mdecrypt.*', $availableFilter)) {
         $app = new App();
         $app->get('/foo', function ($req, $res) {
             $key = base64_decode('xxxxxxxxxxxxxxxx');
             $iv = base64_decode('Z6wNDk9LogWI4HYlRu0mng==');
             $data = 'Hello';
             $length = strlen($data);
             $stream = fopen('php://temp', 'r+');
             $filter = stream_filter_append($stream, 'mcrypt.rijndael-128', STREAM_FILTER_WRITE, ['key' => $key, 'iv' => $iv]);
             fwrite($stream, $data);
             rewind($stream);
             stream_filter_remove($filter);
             stream_filter_append($stream, 'mdecrypt.rijndael-128', STREAM_FILTER_READ, ['key' => $key, 'iv' => $iv]);
             return $res->withHeader('Content-Length', $length)->withBody(new Body($stream));
         });
         // Prepare request and response objects
         $env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo', 'REQUEST_METHOD' => 'GET']);
         $uri = Uri::createFromEnvironment($env);
         $headers = Headers::createFromEnvironment($env);
         $cookies = [];
         $serverParams = $env->all();
         $body = new RequestBody();
         $req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
         $res = new Response();
         // Invoke app
         $resOut = $app($req, $res);
         $app->respond($resOut);
         $this->assertInstanceOf('\\Psr\\Http\\Message\\ResponseInterface', $resOut);
         $this->expectOutputString('Hello');
     } else {
         $this->assertTrue(true);
     }
 }
開發者ID:hidayat365,項目名稱:phpindonesia.or.id-membership2,代碼行數:39,代碼來源:AppTest.php

示例4: dispatchResponse

 private function dispatchResponse(ResponseInterface $response)
 {
     $this->slimApp->respond($response);
 }
開發者ID:postalservice14,項目名稱:sainsburys-http-service,代碼行數:4,代碼來源:SlimAppAdapter.php


注:本文中的Slim\App::respond方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。