Slim3 CLI的模拟环境

问题描述:

我想模拟一个环境来启用slim3 cli接口。Slim3 CLI的模拟环境

#!/usr/bin/env php 
<?php 
array_shift($argv); 
$pathInfo = implode('/', $argv); 

if (empty($pathinfo)) { 
    $pathinfo = '--help'; 
} 
$config = ['environment'=>\Slim\Http\Environment::mock(['REQUEST_URI' => $pathInfo])]; 
$app = new \Slim\App($config); 

$app->get('test:output',function(){ 
    exit("Arrived!"); 
}); 

$app->run(); 

但是,当我运行代码php bin/run test:example绝对没有任何反应。

如果我陷入请求并获取请求URI,它将返回为“/”。

有没有其他人有这个问题,并得到了它?

在此先感谢

似乎REQUEST_URI不不启动/工作。详情请参阅this question

另请参阅Cilex - CLI命令的特殊框架,而不是HTTP路由。

+0

谢谢。我最终做出了我自己的! –