Content of the «Handling Requests» section:
- Request Handling Overview
- Routing and URL Creation
- Sessions and Cookies
- Handling Errors
Articles section «Handling Requests»:
Yii provides a powerful logging framework that is highly customizable and extensible.Using this Yii framework, you can easily log various types of messages, filter them, and gather them at different targets, such as files, databases, emails.
Yii includes a built-in [[yii\web\ErrorHandler|error handler]] which makes error handling a much more pleasant experience than before. The [[yii\web\ErrorHandler|error handler]] is enabled by default. In particular, the Yii error handler does the following to improve error handling.
Sessions and cookies in Yii 2 allow data to be persisted across multiple user requests.Yii encapsulates sessions and cookies as objects and thus allows you to access them in an object-oriented fashion with additional useful enhancements.
The response object contains information such as the HTTP status code, HTTP headers and body. When an application finishes handling a request, it generates a [[yii\web\Response|response]] object and sends it to the end user.
For a given request, you can get access to the corresponding request object via the request application component which is an instance of [[yii\web\Request]], by default. Requests made to an application are represented in terms of [[yii\web\Request]] objects which provide information such as request parameters, HTTP headers, cookies, etc.
Routing and URL Creation in Yii 2. When a Yii application starts processing a requested URL, the first step it takes is to parse the URL into a route. The route is then used to instantiate the corresponding Yii controller action to handle the request. This whole process is called routing.
Bootstrapping Yii is done in two places: the entry script Yii and the application Yii. In the entry script, class autoloaders for different libraries are registered. This includes the Composer autoloader through its autoload.php file and the Yii autoloader through its Yii class file.
Request Handling Overview a Yii application. Each time when a Yii application handles a request, it undergoes a similar workflow. The following diagram shows how an application handles a request.