After finishing the processing of the request object, Yii2 then generates a response object, which is sent back to the client. The response contains a myriad of information, such as the HTTP status code, response body, and headers. In Yii2, the response object is implemented by
yii\web\Response, which is represented by the
response application component. In this section, we'll explore how to work with responses.
In most cases, Yii2 is perfectly capable of setting the appropriate response code back to the end user; however, there may be situations that require us to explicitly define the HTTP response code for our application. To modify the HTTP status code within our application, we simply need to set