Skip to main content

Process of page request to response in Drupal 8 - Part 1

For every drupal developer is it necessary to know the under the hood process of how drupal internally works and some of them may already know  page rendering process of drupal 7.

Lets see the Process of User Request to Response in  two parts:





PART 1:


Step 1:  The user make a request in the browser in the form of url for example: www.example.com


Step 2:  The browser will pass the request to the Web server where the website  resides(Here Drupal makes website...)

Step 3: In drupal , every request is handled via index.php file ,while digging into index file we may see the following lines as shown in the image.



Note:  Symfony is a playing a major role  in  drupal 8 and drupal 8 follows the object oriented style of programming..


Components used from symfony in drupal 8.




 So as you see , there is a two use statements 

1.use Drupal\Core\DrupalKernel
2.use Symfony\Component\Httpfoundation\Request.


Drupal and Symfony communicate between themselves to determine how an incoming HTTP request should be dealt with, to generate the response, and to deliver the response back to the browser.

Class DrupalKernel:


        This class is responsible for building the Dependency Injection Container and also deals with the registration of service providers. It allows registered service providers to add their services to the container.


DrupalKernel retrieves the Symfony HttpKernel and calls HttpKernel::handle($request).The HttpKernel::handle() method works internally by dispatching events.

Interacting to httpkernel is done via getHttpKernel method which in turn retrieves 
 the http_kernel service from the container.

To further information about httpkernel use this link HttpKernel

Class Request :
Request represents an HTTP request.

The methods dealing with URL accept / return a raw path (% encoded): * getBasePath * getBaseUrl * getPathInfo * getRequestUri * getUri * getUriForPath

$request = Request::createFromGlobals();


  1. $_GET
  2. $_POST
  3. $_SESSION
  4. $_REQUEST...etc

Creates a new request with values from PHP's super globals.

/ actually execute the kernel, which turns the request into a response
// by dispatching events, calling a controller, and returning the response
$response = $kernel->handle($request);


    Internally, the HttpKernel::handle() method first calls getController() on the controller resolver. This method is passed the Request and is responsible for somehow determining and returning a PHP callable (the controller) based on the request's information.



We will discuss the about response object further into part 2.











Comments

Popular posts from this blog

Redirection In Drupal 8 Programatcially

Redirection In Drupal 8  In this post we can learn about the ways we can make redirect in Drupal 8. You can make a custom redirect according to the context in many ways. Form Redirect      We can use the formstate object to redirect from form.     Currently below two methods are available from Drupal\Core\Form  formstate to build  a    \Symfony\Component\HttpFoundation\RedirectResponse  for redirection. 1) setRedirect  function setRedirect($route_name, array $route_parameters = [], array $options = []) This method will call the setRedirectUrl function inside it. 1) route_parameters - optional argument 2) route_name -  The name of the route name. 3) options -    (optional) An associative array of additional URL options, with the    *   following elements:    *   - 'query': An array of query key/value-pairs (without any URL-encoding)    *...

Things You Must Know Before Trying Forms In Drupal 8.

 You Should Invest In Forms                      What does your customer think?  What do they looking for? will decide the success of any business.    In a digital marketing, Most of the customer requirement is gathered through forms. So its   essential  to spend some  time with forms Example : a user can search a particular product using the search form on an e-commerce website. Form API in Drupal 8          As we know already Drupal use forms for most of the administrative site building. Drupal 8 follows object-oriented style of programming with the integration of symfony . Based on the purpose of the form, it can inherit the basic properties and methods of the below classes. 1.Config Base 2.FormBase 3.ConfirmBase   Note : Routing configuration is done through the yml files in drupal 8 When the user hits the va...

What is Drupal ? What is Content Management System??

Before  Diving into Drupal 8 Learning ,                                                One who must know what is drupal . What is Drupal ? Drupal  is one among the Content Managment System . Then next rising  question is What is   Content Management System  . ?   To explain about Content Mangement System lets start with an example If you want to sell your products in online , you can sell by passing some of the information about your product in web by giving Name of the Product Image of the Product  Price of the Product ....etc As a whole you are describing your content For managing large amount of data like this you need a system for flexibility  and ease of use So you may think like developing a system from scratch to sell a product Ohhhhh !!!!!!!!!!!!!!!!!!!!!!!Nooooooooooooooooo!!!! ...