当前位置: 首页>>代码示例>>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;未经允许,请勿转载。