Answer the question
In order to leave comments, you need to log in
How to specify options for XmlResponseFormatter?
I didn't quite understand how to use XML response in Yii2.
We need to change the root tag.
www.yiiframework.com/doc-2.0/yii-web-xmlresponsefo... - how to specify this? action:
public function actionMy()
{
Yii::$app->response->format = Response::FORMAT_XML;
return ['...'];
}
Answer the question
In order to leave comments, you need to log in
XmlResponseFormatter settings can be specified in the application configuration, like so:
'components' => [
'response' => [
'formatters' => [
'xml' => [
'class' => '\yii\web\XmlResponseFormatter',
'rootTag' => 'mytag'
]
],
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question