如何在框架phpixie上提出请求

时间:2018-09-21 15:40:38

标签: php phpixie

我有以下代码:

$framework = new \Project\Framework();
//$framework->registerDebugHandlers(false, false);

$slice = new \PHPixie\Slice();
$http  = new \PHPixie\HTTP($slice);

$serverRequest = new PHPixie\HTTP\Messages\Message\Request\ServerRequest\SAPI(
    $http->messages(),
    [
        'REQUEST_METHOD'  => 'GET',
        'REQUEST_URI'     => 'http://localhost/v/param',
        'SERVER_NAME'     => 'localhost',
        'SERVER_PROTOCOL' => 'HTTP/1.1',
        'HTTP_HOST'       => 'localhost',
        'Content-Type'    => 'application/text',
    ],
    ['get'    => 1],
    ['post'   => 1],
    ['cookie' => 1],
    ['files'  => 1],
    [
        'enc_params' => 'param',
    ]
);

var_dump($framework->processHttpServerRequest($serverRequest)->getBody());

如果您通过控制台运行此代码,我会得到:

  

PHP注意:未定义的索引:第45行/vendor/phpixie/http/src/PHPixie/HTTP/Messages/Message/Request/ServerRequest/SAPI.php中的REQUEST_METHOD

尽管会收到该页面

我试图在页面顶部插入以下代码,但没有帮助

$_REQUEST = [
    'REQUEST_METHOD' => 'GET',
    'REQUEST_URI'    => 'http://locahost/v/param',
];

如果您通过浏览器调用此代码,则一切正常

0 个答案:

没有答案