Exploring the Core Project
What is it?
I've been using TYPO3 for a while and have also been involved in extension development a bit (although I haven't published much, yet). However, I always find that I don't know enough about the Core API. Although the Core API is documented, it is sometimes hard to find your way through it and just know that there already is a function that would do what you need. That leads to the wheel being re-invented over and over again which cannot be in anyone's interest. Therefore I've decided to start working my way through the Core API systematically to understand TYPO3's "guts". This will hopefully give me with a profound knowledge of what the Core API is able to do and what I have to do myself.
The reason why I set up this project has two sides to it. On the one hand I want to document what I find out, on the other hand I'm looking for like-minded people that want to join in here and document their efforts and findings. I believe that this will help improve TYPO3's documentation which I still consider one of the few weaknesses of the project (although it could be a lot worse!). So let's get some work done and take a load off the developers shoulders. If your PHP knowledge is good enough to read TYPO3 code, just join in. Put you name down below, so that everyone knows you're in. Everything else will just develop over time.
- Jsfan (Cerebrum (Aust) Pty Ltd, Melbourne, Australia)
- Tan Le (tanle.net) Melbourne Australia
- Daniel (geron) Gohlke (siteworxxx) Jena Germany
- Peter Niederlag; Hannover, Germany
I'm not sure how to start here, so I'll try to just set up a list of files that I have gone through trying to create a road map that enbales others to follow me through the core code. I'm usually using the latest version (currently 4.1RC2).
As with any PHP project, I start at the main index.php, which is the index.php on the highest level in the source directory. This file is not very complex. It only sets the constants PATH_site and PATH_tslib and then goes on to require PATH_tslib.'index_ts.php' which usually resolves to typo3/sysext/cms/tslib/index_ts.php
One thing worth mentioning is that you can set the path for tslib in this file in case it cannot be found automatically. This leaves you the option to install tslib separate from the rest of the source (for whatever reason you would want to do that) but is probably meant to be used for failed detections only.
This script sets $TYPO3_MISC['microtime_start'], the constants TYPO3_OS and TYPO3_MODE (always FE here), PATH_thisScript (if not already defined), PATH_site (if not already defined), PATH_t3lib (if not already defined), TYPO3_mainDir (hard coded to '/typo3'), PATH_typo3 (Path_site + TYPO3_maindir), PATH_typo3conf (Path_site + '/typo3conf') and PATH_tslib (if not already defined).
It then tries to load the configuration and prints an error message if the attempt fails.
Then it creates an instance of t3lib_timeTrack (includes class.t3lib_timetrack.php from the t3lib directory first) and starts this object with the message 'Script start' to track time. The time tracking will not be mentioned any more but is used all over the following steps.
Mandatory libraries are now loaded by including the files class.t3lib_div.php and class.t3lib_extmgm.php from the t3lib directory.
The default configuration from config_default.php in the t3lib directory is loaded and the script checks if the cms extension is loaded.
The $TYPO3_DB object is instantiated. Client is set according to browser using t3lib_div::clientInfo().
TYPO3 now makes sure that the PHP version is at least 4.3.0 and dies with an error if the test fails.
Next comes a check for values for the variable GLOBALS sent from the client. If there are values, execution stops with an error.
Data from client is escaped if magic_quotes_gpc not set in PHP configuration.
If eID was in the parameters sent by the client, $TYPO3_CONF_VARS['FE']['eID_include'][<eID value from client input>] is checked and the corresponding class loaded along with the tslib component class.tslib_eidtools.php.