Yii allows us to create a custom format response to output data. The response format can be changed based on the
Accept HTTP header sent by the client or done programmatically. When Yii receives a request, it searches for an available response formatter based on the
Accept HTTP header value and finally calls the
$response) method of the response formatter found.
Therefore, there are three steps to create custom responses:
behaviors()method of the controller to handle specific
AcceptHTTP header values.
The first step requires us to implement the