If you really want to evolve from a web developer skillful enough to put together a functional “puzzle” out of Drupal's core modules, to one custom-making his new modules, then you need to take a close look at the whole process behind this apparently simple sequence: “you hit an URL, then (as if by magic) the required page instantly gets loaded”.
 
So, ready to take a sneak peek “behind the curtains”? If yes, then allow us to be your guide!
 
 

1. Drupal Separates The Internal Path from the Domain Name

 
Once the server gets the message, once the URL is sent, Drupal focuses on the internal path and on it only. Therefore, it just “cuts it off” from the URL.
 

2. Then Drupal Calls Index.php

 
Take the index.php as some sort of a “control tower” (you can find it in the root directory of the Drupal install), the one that processes all the incoming requests. 
 
Now, let's have a closer look! Index.php is made of 4 lines, each one of them performing a certain function:
 
  • define('DRUPAL_ROOT', getcwd(): the very first line that runs once Drupal gets a page request
  • require_once DRUPAL_ROOT . '/includes/bootstrap.inc': its role is that of loading  bootstrap.inc in the includes/subdirectory.bootstrap.inc
  • drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL): it loads pretty much everything: the modules and functions, the needed data into the memory...
  • menu_execute_active_handler(): as the name says it, it's the one actually handling the page request, delivering the final web page to the end user 
 

3. Now Drupal Goes Through the Bootstrap Process

 
This is where the “major loading” happens: it is now that Drupal loads the libraries, initializes the database, sets the right sessions... 
 
The bootstrap process a self-start one, requiring no input, no intervention from you, the website's “creator”, and yet... you can't possibly not know what happens during this whole process running on its own!
 
How about going rapidly through all the 8 phases of this highly complex bootstrapping process?
 
1. DRUPAL_BOOTSTRAP_CONFIGURATION: Drupal calls upon it wherever it encounters php errors or exceptions. If so, then an error handling code is prepared, settings.php gets loaded, configuration gets initialized...
 
2. DRUPAL_BOOTSTRAP_PAGE_CACHE: it checks whether the IP is blocked or not, whether the cache is enabled or not in order to serve the page from the cache
 
3. DRUPAL_BOOTSTRAP_DATABASE: it loads the database and checks whether any $databases array has been defined. If no, then it redirects to install.php
 
4. DRUPAL_BOOTSTRAP_VARIABLES: it loads the variables from the database variables table, then it overwrites the ones defined in settings.php, while loading all the other modules needed during this process   
 
5. DRUPAL_BOOTSTRAP_SESSION: it initializes the session handlers. There are several custom session handlers in Drupal:
 
  • _drupal_session_open() and_drupal_session_close(): to open and close a connection
  • _drupal_session_read(): gets the session from the sessions table
  • _drupal_session_write(): checks whether the session has been updated and writes a new one to the databse
  • _drupal_session_destroy(): it deletes cookies and cleans up a specific session
  • _drupal_session_garbage_collection(): it deletes the outdated sessions
 
6. DRUPAL_BOOTSTRAP_PAGE_HEADER: it practically sets up the HTTP header
 
7.  DRUPAL_BOOTSTRAP_LANGUAGE: called upon only for multilingual websites, it initializes the right language for the future web page
 
8. DRUPAL_BOOTSTRAP_FULL: the very final step, where all the modules are enabled and hook_init() is invoked
 
 

4. Drupal's Menu System Steps In

 
From all of Drupal's modules, it's the menu system that “guides” the internal path to a callback function.
 

PATH... MODULE... MENU SYSTEM... CALLBACK FUNCTION... LOAD CONTENT

 

5. Finally, It's the Theme System That Styles the Requested Page

 
Being more than just a theme (since it's a mix of theme functions and templates), the theme system is the one “dictating” the content/ the web page's final look. 
 

CONTENT... THEME SYSTEM (CSS, HTML, JS etc.)... BROWSER

 
Of course that each process of this whole page request handling mechanism in Drupal requires a lot more in-depth knowledge, but this is pretty much the overall mental scheme that each developer should know for:
 
1. boosting his self-confidence with powerful knowledge
 
2. being able to come up with his own future custom modules    
 
Development

We do Drupal development

Go to our Drupal page!

Visit page!

Browse cities

Recommended Stories

OPTASY Makes it on Clutch’s Industry Game-Changer Ranks
Investing in quality e-commerce solutions is a must in this current digital world. Consumers nowadays love having… (Read more)
5 Minutes /
The Power of Upgrade: Transforming Government Websites with Drupal
Government websites play a vital role in our lives. They are the bridges that connect us to our government,… (Read more)
10 minutes /
Telehealth Revolution: Leveraging CMS for Virtual Patient Care
Telehealth is revolutionizing how we think about healthcare, bringing doctor visits and medical advice straight to… (Read more)
10 minutes /