What happens when you require config.php
All request handling scripts in Moodle must with a line like
with an appropriate number of '../'s. This achieves two main things
- It loads all the Moodle core library code.
- 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.
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.