Drupal 7 - index.php
All requests to a Drupal 7 website (except those which are directly accessing files) are passed to the index.php file. You would think that this file would be quite large and complex, but in fact it is very simple:
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler()
?>It first uses php's getcwd() and define functions to get the site's root directory location and set it as a variable named 'DRUPAL_ROOT'. It then includes the bootstrap.inc file that resides in the 'includes' folder. It then executes the drupal_bootstrap() function, passing it an arugument of 'DRUPAL_BOOTSTRAP_FULL'. This is where the Drupal infrastructure is built up. At this point in time, Drupal should be aware of what page is being requested and should know how to respond accordingly. THe function menu_execute_active_handler() is what finally builds the appropriate page and returns it to the user. Once that function has run, the response is complete. This process is repeated on every single request to a Drupal site.




Comments
Post new comment