Since we are dealing with the core of TYPO3 it might help us to make a totally trimmed down installation of TYPO3 with only the core - then we can see what is actually left...
First of all the general introduction to the source code file structure is found in the "Installing and Upgrading" document. So I'll not be going into details on that here.
For the coming sections in this document I have made a directory "coreinstall" on the same level as an installation of the source code. The "coreinstall" directory is going to be the base directory of the installation (this path is internally in TYPO3 known as the constant "PATH_site"). This is where the website would run from normally.
[root@T3dev 32]# ls -la
total 27768
drwxr-xr-x 21 httpd httpd 4096 Feb 14 14:25 ./
drwxr-xr-x 4 httpd httpd 4096 Jan 16 19:59 ../
drwxr-xr-x 2 httpd httpd 4096 Feb 14 14:25 coreinstall/
lrwxrwxrwx 1 httpd httpd 20 Feb 14 12:05 typo3_src -> typo3_src-3.6.0-dev/
drwxr-xr-x 6 httpd httpd 4096 Jan 30 17:23 typo3_src-3.6.0-dev/
In the directory "coreinstall/" I create a symlink to the typo3/ administration directory:
# ln -s ../typo3_src/typo3/
The lets see what happens if I point my web browser at this directory:
Yes of course - the configuration directory. "typo3conf/" is a local directory which contains site specific files. That can be locally installed extensions, special scripts, special all kinds of things and of course the obligatory "localconf.php" file! In other words: The "typo3conf/" folder of a TYPO3 installation contains local, unique files for the website while the "typo3/" folder (along with others) contains general source code that could have been shared between all installations on a server. Well, read more about this in the Installing and Upgrading document.
Lets create a localconf.php file:
<?php // Setting the Install Tool password to the default "joh316"$TYPO3_CONF_VARS["BE"]["installToolPassword"] = "bacb98acf97e0b6112b1d1b650b84971"; // Setting the list of extensions to BLANK (by default there is a long list set)$TYPO3_CONF_VARS["EXT"]["extList"] = 'install';$TYPO3_CONF_VARS["EXT"]["requiredExt"] = 'lang'; // Setting up the database username, password and host$typo_db_username = "root";$typo_db_password = "nuwr875";$typo_db_host = "localhost";?>
The result will be this:
So we are connected to the server (username and password accepted) but we have not yet defined a database. Lets go create a blank one!
So we go to "coreinstall/typo3/install/index.php" but see this message:
In the main source distribution of Typo3, the install script is disabled by a die() function call.Open the file typo3/install/index.php and remove/out-comment the line that outputs this message!
After having removed the die() function call in the file .../install/index.php file we can enter the Install Tool (password was "joh316" by default). Then go to the "Basic Configuration" menu item.
Then go to the "Database Analyzer":
OK, so we are connected, we have a database. But zero tables. Kein problem:
First "Update required tables" (Click #1 and click "Write to database"),
then "Dump static data" (Click #2, tick off "Import the whole file..." and "Write to database"), then create an "admin" user so you can login (Click #3, enter username/password and accept).
Notice: With a core-only install of TYPO3 there is currently no static table data so this step can be skipped. However it's included here for the completeness.
Now you can go to the typo3/ directory again and you will have a login box:
If you login you will see this:
Finally we will revisit the "Basic Configuration" menu item and check if the rest of the requirements are met:
We find that this is not the case with particularly two directories: uploads/ and typo3temp/. There are a number of other missing directories which issues a warning, but that is because those are typically used with the "cms" extension frontend. That is disabled now. Remember? - Core only!
So
# mkdir typo3temp/
# mkdir uploads/
... and all is fine.
So lets sum up what we have now:
These are the main directories of interest:
Directory | Content | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
t3lib/ | TYPO3 libraries and core database setup (t3lib/stddb/) | |||||||||||||||||||||||||||||||||||||||||||||
typo3/ (shared between all websites) | Source code of the TYPO3 administration backend. Can be symlink'ed to the "typo3_src" source code located elsewhere. Most directories can be write protected except as noted below | ext/ sysext/ | Directories containing extensions. ext/ is for "global" extensions and sysext/ for "system" extensions. Both types are available for all installations sharing this source code. The difference is that global extensions might be missing from the distributed source code (meant to be updated by the EM) while the system extensions are "permanent" and will always be a part of the distributed source. Further you cannot update the system extensions unless you set a certain configuration flag in TYPO3_CONF_VARS NOTE: In case you want to allow the Extension Manager to update global and system extensions you must also allow writing to "ext/" and "sysext/". Install Tool will warn you. | gfx/ | Various graphical elements | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | ext/ sysext/ | Directories containing extensions. ext/ is for "global" extensions and sysext/ for "system" extensions. Both types are available for all installations sharing this source code. The difference is that global extensions might be missing from the distributed source code (meant to be updated by the EM) while the system extensions are "permanent" and will always be a part of the distributed source. Further you cannot update the system extensions unless you set a certain configuration flag in TYPO3_CONF_VARS NOTE: In case you want to allow the Extension Manager to update global and system extensions you must also allow writing to "ext/" and "sysext/". Install Tool will warn you. | gfx/ | Various graphical elements | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | Directories containing extensions. ext/ is for "global" extensions and sysext/ for "system" extensions. Both types are available for all installations sharing this source code. The difference is that global extensions might be missing from the distributed source code (meant to be updated by the EM) while the system extensions are "permanent" and will always be a part of the distributed source. Further you cannot update the system extensions unless you set a certain configuration flag in TYPO3_CONF_VARS NOTE: In case you want to allow the Extension Manager to update global and system extensions you must also allow writing to "ext/" and "sysext/". Install Tool will warn you. | gfx/ | Various graphical elements | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | gfx/ | Various graphical elements | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | Various graphical elements | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | install/ | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | Contains the Install Tool starter-script. Basically this is an index.php-script which initializes a constant that - if defined - will launch the Install Tool. NOTE: Make sure to properly secure access to the Install Tool! | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | mod/ | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | Backend modules. Reflects the old concept of modules and submodules from before extensions hit the scene in summer 2002. Today it contains mostly placeholders, "host modules" and default core modules like the Extension Manager (mod/tools/em). | |
typo3conf/ (specific for each website) | Local directory with configuration and local extensions. Can be used for additional user defined purposes as you like. Must be writeable by PHP. localconf.php: Main configuration of the local TYPO3 installation. Database username, password, install tool password etc. temp_CACHED_xxxxxx_ext_localconf.php temp_CACHED_xxxxxx_ext_tables.php: Auto-generated cache-files of "ext_localconf.php" and "ext_tables.php" files from all loaded extensions. Can be deleted at any time and will be automatically written again. | |||||||||||||||||||||||||||||||||||||||||||||
typo3temp/ (specific for each website) | For temporary files. | |||||||||||||||||||||||||||||||||||||||||||||
uploads/ (specific for each website) | For storage of files attached to database records as managed by the TCE. Strictly this directory (and subdirectories) is only needed if it's configured in $TCA. Also used by default for images inserted into the RTE. |
Basically we completed these steps to create the files and folders of a bare-bone TYPO3 core installation:
Create symlink to the t3lib/ directory (shared)
Create symlink to the backend administration directory, typo3/ (shared)
Create directories typo3conf/, uploads/, typo3temp/ (specific)
Create typo3conf/localconf.php file and add a minimum of configuration to get started. (specific)
There are two (sometimes more) files which we didn't create ourselves; the cached "temp_CACHED_xxxxxx_ext_localconf.php" and "temp_CACHED_xxxxxx_ext_tables.php". These two files are automatically compiled from the currently loaded extensions and written to disk. If you look into the files you can see that they are just scripts automatically collected from the loaded extensions, then concatenated and written to disk. This concept improves parsing a lot since it make it possible to include one file (the cached file) instead of maybe 50 files from different locations.
WARNING: If you install an extensions which has a parsing error in either the "ext_localconf.php" file or "ext_tables.php" file you will most likely be unable to use either frontend, backend or Install Tool before this problem is fixed. You fix the problem by using a shell or ftp to 1) edit localconf.php file, removing the "bad" extension key from the list of installed extensions, then 2) remove the cached files and 3) hit the browser again (cached files will be rewritten, but without bad files). Of course the long term solution is to fix the parsing error...
The file contained
A password so we could enter the Install Tool
An extension list with only the "install" extension set (Install Tool). Normally there are a long list of default extensions listed.
A required extensions list set to only the "lang" extension (all the labels for the backend interface). (Required extensions cannot be disabled by the EM)
Database setup information, including the database name (added by Install Tool after database creation).
Looking into the backend of our "bare bone" install this is what we see:
Notice how few modules are available! This is the default set of features which exists in what we call the core of TYPO3! If you go to the Extension Manager (EM) and enable "Shy extensions" you can see that only the "lang" and the "install" extensions are there. Even the Install Tool is an extension that can be disabled.
After these steps you have also created a database and populated it with a default set of tables. So how did the Install Tool know which tables were needed? Simple answer: The Install Tool simply reads the core sql-file (t3lib/stddb/tables.sql) plus similar files for every installed extension ([extension_dir]/ext_tables.sql) and adds it all together into a requirement for the fields and keys of the tables! Thus the database will always have the correct number of tables with the correct number and types of fields!
NOTICE: You cannot necessarily pass these sql-files directly to MySQL! If you look into the file t3lib/stddb/tables.sql you can find a table definition like this:
#
# Table structure for table 'cache_hash'
#
CREATE TABLE cache_hash (
hash varchar(32) DEFAULT '' NOT NULL,
content mediumblob NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
ident varchar(20) DEFAULT '' NOT NULL,
PRIMARY KEY (hash)
);
And in some extension (myextension) you could find something along these lines:
#
# Table structure for table 'cache_hash'
#
CREATE TABLE cache_hash (
tx_myextension_additionalfield varchar(20) DEFAULT '' NOT NULL,
);
The first "CREATE TABLE" query will execute just fine if you "pipe" it into MySQL directly, but the second one will not! And it was not intended to!
The reason is that IF myextension is installed then the Install Tool will read both files and automatically compile the final query into this:
CREATE TABLE cache_hash (
hash varchar(32) DEFAULT '' NOT NULL,
content mediumblob NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
ident varchar(20) DEFAULT '' NOT NULL,
tx_myextension_additionalfield varchar(20) DEFAULT '' NOT NULL,
PRIMARY KEY (hash)
);
If we install the "phpmyadmin" extension we can browse the database tables from the backend:
As we can see the number of required tables for a minimum install of TYPO3 is really just 13 tables!
Tablename | Description |
|---|---|
pages | The "directory tree" (page tree) backbone of TYPO3s database organization concept. |
be_groups be_users be_sessions sys_filemounts | Tables with backend user groups and users plus a table for storing their login sessions. sys_filemounts are used to associate users/groups with filepaths where they can upload and manage files. |
cache_hash cache_imagesizes | Multi purpose table for storing cached information (cache_hash) and cache table for image sizes of temporary files. |
sys_be_shortcuts | Stores the shortcuts users can create in various backend modules |
sys_history | Contains the history/undo data |
sys_lockedrecords | Keeps track of "locked records" - basically who is editing what at the moment. |
sys_log | Backend log table - logs actions like file management, database management and login |
sys_language | System languages for use in records that are localized into certain languages. |
sys_workspace | System workspaces for editing of content in “offline” mode or in projects. |
Even if you look at the "pages" you will quickly see that the core pages table miss a lot of the fields and features applied to it when used under "CMS conditions". All meta-fields are gone, all content management related fields are gone. Left is only a set of general purpose options:
And the point is; TYPO3s inner identity is that of a framework which by additional extensions can be dressed up for the purpose it needs to fulfil. 99% of all people who are using TYPO3 will see the "dressed up version" designed for web content management. However my claim is that if you really want to understand TYPO3 you must get down to the core, to the principles which lay the foundation of it all. If you have a firm grip on these central principles then you will quickly understand or be able to analyze how each extension on top of it works. And you as a developer will be able to help the continual development along consistent lines of thought.
Welcome Inside of TYPO3!
- kasper