Drupal/How it Works

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

index.php

Everything starts at index.php.

The file is simple. It does the following:

require_once './includes/bootstrap.inc';

We'll talk more about bootstrap.inc later.

Next it does the bootstrap for each request:

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

This will load the configuration and a number of other things.

$return = menu_execute_active_handler();

This is like 'main()' in other programming languages, but for Drupal.

If there's an error, it will call:

  • drupal_not_found() if MENU_NOT_FOUND
  • drupal_access_denied() if MENU_ACCESS_DENIED
  • drupal_site_offline() if MENU_SITE_OFFLINE

If there are no errors, then it calls 'theme()'.

 print theme('page', $return);

Finally, it prints the footer, on every page.

drupal_page_footer();

includes/bootstrap.inc

bootstrap.inc defines a number of constants. It also has a number of functions. This is the heart of drupal, while index.php is merely the front door.

drupal_bootstrap()

drupal_bootstrap() bootstraps Drupal. It does so by bootstrapping phases one after the other.

menu_execute_active_handler()