Here ? So, I am assuming we have some idea of Symfony2 and it's components used in Drupal 8
by now.
Great, let's move ahead. Every web interaction as we know starts with a request and ends with a
response, same goes here with Drupal 8. We send a request and receive some response from
Drupal but what goes internally ? Let's dive in and find out.
Of all the important components of Symfony2 being used in Drupal 8, HTTPKernel and
HTTPFoundation plays an important role in handling a page request but this time the proces uses
an object oriented way.
Ohh.. big names :) Let's know something more about these.
HTTPKernel: This component consists of an HTTPKernelInterface which provides a method,
handle(). This method accepts $request object as parameter and returns $response object.
HTTPFoundation: This component is responsible for creating and managing the $request and
$response objects. We can say that, it's an object oriented replacement of superglobals being
generally used for handling a page request.
The above mentioned interface doesn't really care about what happens inside the handle()
method, it's the responsibility of the class implementing it, giving the whole process a level of
abstraction.
Similar to Drupal 7, here also a request is initiated from index.php. The request is then passed to
HTTPKernel::handle() method. As we know, the working inside the handle() method is an event
driven process. Let's go deeper to find out the series of events involved in it.
kernel.request: This event does the work of initialization, adding more relevant information to the
request object. Few of the listeners to this event have enough information to produce a response
immediately, thus skipping further steps. And if a response object is not created, then the
controller specific to the type of request is determined using controller resolver.
kernel.controller: Once a controller is determined for the request, this event gets executed. This
allows us to change the controller that will handle the request. The purpose again is to produce a
response object. If this step returns a response object then further steps are skipped and
kernel.response is executed or else kernel.view comes into play.
kernel.view: This event converts non-Response result of the controller into a proper response
object. Drupal renders this output using twig templating system. Till now if no response object is
created then an exception is thrown. Controller or one of the listeners of this event handles the
exception.
kernel.response: Irrespective of which of the above mentioned events created the response
object, kernel.response event is directly dispatched after that. The response object is finally
modified by the listeners to this event and then sent back to handle() method.
So, this was the journey of a page request being converted to a response object. However, this is
just an overview, we still can go deeper to find out more details. Give it a shot.
I just started trying my hands in Drupal 8 and while trying I prefer sharing but my understanding
may go wrong. So, feedbacks and corrections are highly appreciated in comments.
by now.
Great, let's move ahead. Every web interaction as we know starts with a request and ends with a
response, same goes here with Drupal 8. We send a request and receive some response from
Drupal but what goes internally ? Let's dive in and find out.
Of all the important components of Symfony2 being used in Drupal 8, HTTPKernel and
HTTPFoundation plays an important role in handling a page request but this time the proces uses
an object oriented way.
Ohh.. big names :) Let's know something more about these.
HTTPKernel: This component consists of an HTTPKernelInterface which provides a method,
handle(). This method accepts $request object as parameter and returns $response object.
HTTPFoundation: This component is responsible for creating and managing the $request and
$response objects. We can say that, it's an object oriented replacement of superglobals being
generally used for handling a page request.
The above mentioned interface doesn't really care about what happens inside the handle()
method, it's the responsibility of the class implementing it, giving the whole process a level of
abstraction.
Similar to Drupal 7, here also a request is initiated from index.php. The request is then passed to
HTTPKernel::handle() method. As we know, the working inside the handle() method is an event
driven process. Let's go deeper to find out the series of events involved in it.
kernel.request: This event does the work of initialization, adding more relevant information to the
request object. Few of the listeners to this event have enough information to produce a response
immediately, thus skipping further steps. And if a response object is not created, then the
controller specific to the type of request is determined using controller resolver.
kernel.controller: Once a controller is determined for the request, this event gets executed. This
allows us to change the controller that will handle the request. The purpose again is to produce a
response object. If this step returns a response object then further steps are skipped and
kernel.response is executed or else kernel.view comes into play.
kernel.view: This event converts non-Response result of the controller into a proper response
object. Drupal renders this output using twig templating system. Till now if no response object is
created then an exception is thrown. Controller or one of the listeners of this event handles the
exception.
kernel.response: Irrespective of which of the above mentioned events created the response
object, kernel.response event is directly dispatched after that. The response object is finally
modified by the listeners to this event and then sent back to handle() method.
So, this was the journey of a page request being converted to a response object. However, this is
just an overview, we still can go deeper to find out more details. Give it a shot.
I just started trying my hands in Drupal 8 and while trying I prefer sharing but my understanding
may go wrong. So, feedbacks and corrections are highly appreciated in comments.
Comments
Post a Comment