What happens when you require config.php: Difference between revisions
David Mudrak (talk | contribs) mNo edit summary |
David Mudrak (talk | contribs) m (Text replacement - "<code php>" to "<syntaxhighlight lang="php">") |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
All request handling scripts in Moodle must with a line like | All request handling scripts in Moodle must with a line like | ||
< | <syntaxhighlight lang="php"> | ||
require(__DIR__. '/../../config.php'); | require(__DIR__. '/../../config.php'); | ||
</ | </syntaxhighlight> | ||
with an appropriate number of '../'s. This achieves two main things | with an appropriate number of '../'s. This achieves two main things | ||
# It loads all the Moodle core library code. | # It loads all the Moodle core library code. |
Latest revision as of 20:38, 14 July 2021
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
- 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.