?请注意Yaf版本,测试3.2.5版在cli模式下Yaf_Request_Simple无法设置$params
//php yaf.php test/test/test aaa bbb #aaa,bbb是参数
$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");
if(php_sapi_name()=="cli"){
//加载cli的bootstrap配置内容
$application->bootstrap();
$uri_r = explode('/',$argv[1]);
if($uri_r[2]){
}elseif($uri_r[1]){
array_unshift($uri_r,'index');
}else{
exit('uri error!');
}
list($module,$controller,$action) = $uri_r;
$params = array_slice($argv,2);
//改造请求
$Request = new Yaf_Request_Simple('CLI',$module,$controller,$action,$params);
//启动
$application->getDispatcher()->dispatch($Request);
}else{
$application->bootstrap()->run();
}
在调用方法中使用$this->getRequest()->getParams()获取参数
|