Drupal 8 Page Call Process

Let's talk about the page call process in drupal 8
Drupal 8 utilization and architecture where index.php acts as front controller, Drupal runs on php.





















So you open index.php and you can see two main classes utilize here.
1: DrupalKernel That was regionally based on Symfony http based Kernel and the
2: HttpFoundation\Request Symfony class component http foundation request
While studying the routing system and controllers I wanted to have an overview of the total page call process and made this diagram. 


Overview of the Drupal 8 page call process

Request
                             

The HTTP request to the website. For example requesting the homepage of the site. The Symfony kernel uses a request object which represents this HTTP request. It is a very important object as all kinds of information will be stored in it which is used to handle the request. Drupal uses this request object to add its own data to it. In Drupal this request object may contain for example: HTTP Get/Post data, HTTP request header and cookie, current user and session, current language.


Router

The router determines what should be done with the request. The router prepares the request to be processed. Here the user data and the current language are added to the request object. But the core task of the router is to do routing; to match the requested URL to a class and method which will be used to process to the request. The router itself does not respond to the request, it only determines what should be done with it. The router also check if access permitted.

Controller

The controller builds the response for the given request. This could be a HTML page, a JSON string or anything else. For normal website pages the controller will return a render array, but the controller can also return for example JSON type data.

View

The View creates the response. Drupal will render the render array using the Twig templating system. The HTTP output is stored in a response object. This response object is what the Symfony kernel uses to store the response in while preparing it. When completed the HTTP response will be returned.

Response

The response is what the website returns at the end of the call. In case of a page call this response will be a HTTP message with a status code 200 (Ok). But other responses like 'Not found' or 'Forbidden' may also occur if either the path is unknown or access is denied. Besides HTTP the response can be of different type such as JSON.

















No comments:

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...