私はこのコードベースに取り組んできましたが、サイトwww.site.com/version/にアクセスするとhtmlで応答します。
ただし、www.site.com / version?format = xmlにアクセスすると、出力がxmlで表示されます。
フォーマット要求に関係なく、ZendコードをXMLでのみ出力するように変更するにはどうすればよいですか?ええ、私はZendコーディングに不慣れです...)
私のコードはまさにクリスが持っているものです(http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/):
class VersionController extends Zend_Rest_Controller
{
public function init()
{
$bootstrap = $this->getInvokeArg('bootstrap');
$options = $bootstrap->getOption('resources');
$contextSwitch = $this->_helper->getHelper('contextSwitch');
$contextSwitch->addActionContext('index', array('xml','json'))->initContext();
//$this->_helper->viewRenderer->setNeverRender();
$this->view->success = "true";
$this->view->version = "1.0";
}
...
...