Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

What happens when you require config.php

From MoodleDocs
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

All request handling scripts in Moodle must with a line like

require(__DIR__. '/../../config.php');

with an appropriate number of '../'s. This achieves two main things

  1. It loads all the Moodle core library code.
  2. In initialises a lot of things like the database connection, the session, the current course, theme and language.

The most reliable way to find out exactly what is going on is to actually go and read the code for config.php, lib/setup.php and the library functions they call. However, the following diagram gives an overview of some of the most important points.

Moodle startup.png

That diagram was drawn looking at the Moodle 2.0 dev code, but it should be similar for most recent version. It is about to change a lot in 2.0 dev over the next few months.

Here is the same image as a .dia file that can be edited with the open source drawing program of the same name: File:Moodle startup.dia.

See also