Check out my visual testing tool https://diffy.website. It helps to save testing time during deployments and development.
We all know that Symfony is already in the core of Drupal 8 but how it works and how both systems work? Not that many people understand fully this integration. Me neither but I would like to pubilsh my research notes about how Drupal 8 works now. Surely this material is based on the snapshot of beginning September and I really hope that more things will happen so this information is relevant only for some time.
I don't have any real life experience of the building projects with Symfony so my knowledge is very close to majority of drupal developers.
So lets start.
First changes we see in index.php that bootstrap is done on the level of DRUPAL_BOOTSTRAP_CODE instead of DRUPAL_BOOTSTRAP_FULL like in Drupal 7. From documentation about phases of bootstrap of Drupal 8 we can see that phase that “initialize language, path, theme, and modules” is not done yet.
Next thing we see that we instantiate object of the DrupalKernel class (inherits from Symfony Kernel class).
Kernel class in Symfony is responsible for building Dependency Injection Container and registering bundles. We will come back to Dependency Injection Container later. Bundles are like “modules” of drupal world.
Next thing that happens that we instantiate Request object (instance of Symfony HttpFoundation component). This is the object that grabs all global variables form the request and has methods to retrieve them. The idea behind it is that we do not use any global variables in the code anywhere but interact only with this object as a source.
Next part is simple ask kernel object to handle our request
$response = $kernel->handle($request)->prepare($request)->send(); $kernel->terminate($request, $response);
Now lets take a look of internals of the kernel object and what it does to handle our request.
Kernel handle method calls $this->boot() method and then $this->getHttpKernel()->handle($request, $type, $catch);
Booting of the Kernel consists of following steps:
After booting the kernel we run its handler method. It comes down firing KernelEvents::REQUEST event where our routing system plays its role. I believe new routing system deserves separate article. After event we have controller we fire event KernelEvents::CONTROLLER that resolves menu callback (in terms of our old menu system). After executing menu callback we fire KernelEvents::VIEW event and our subscribers prepare $response object that is finally returned.
Having response object avaialble we run prepare( ) method that prepares headers, and run send( ) method that prints rendered output.
Finally we run kernel's terminate method that in the end fire KernelEvents::TERMINATE event.
This is very brief overview from the beginner point of view to the system. I hope it made some feeling of understanding of how things work now or at least triggered your interest to learn more about it. Also please remember that things are changing as this are parts that are in active development right now.
Comments
nice article on drupal and symfony2
moderate comments!!
Comments spam cleared. Sorry