[TYPO3-core] Naming of Files and Classes

Benjamin Mack benni at typo3.org
Thu Jun 21 08:06:57 CEST 2012


Hey fellow developers,

this time I want to take a quick break and say a big thanks to everybody
involved in making the TYPO3 Core better. I see T3 heading in a great
direction with 6.0 and I am already starting projects with the latest
trunk. Can't wait to have this as a new stable basis!

One of the major things I noticed since 4.5 is that we're finally
straightening out the glitches we had for so long, and taking bigger
steps forward. PHP 5.3 as a dependency, dropping IE6 support, closer
integration with Extbase/Fluid and now, refactoring file handling and
bootstrap just gets better and better.

In the past, we often had discussions about introducing namespaces,
renaming classes and files in order to achieve better consistency. Now,
I want to pick up the discussion again while differentiating between the
separate issues.

At the end of this conversation I'd love to have a better situation and
a plan for 6.x (maybe even 6.0 already) by honoring the following
parameters:
 * Get closer to the F3 naming scheme
 * Keep maximum backwards compatibility with the existing code


Ground Rule #1: One class per file
- currently not done everywhere in the Core - check template.php e.g.


Ground Rule #2: Consistent class naming
- This might be a problem, especially when I think of stupid class names
like "TBE_localpagetree" or "localfoldertree" (multiple instances of
that available), "TYPO3AJAX" or "ModuleMenu" (no prefix).


Here are some ideas that I think should be easily done:


Discussion A: File Naming and Structuring
Now that we finally have almost all classes loaded via the autoloader it
should be fairly easy to move them around. I'd love to have

  t3lib/Classes/
  typo3/Classes/

and have every class in there, Naming Scheme follows FLOW3 naming scheme
(Subfolders etc).


I think this could be done within the scope of 6.0 -- IF we agree on it.


Discussion B: Class Naming (see Ground Rule #2)
I suggest to introduce a prefix "t3lib_" (which we already have) for all
t3lib/ files, and "T3_" to all non-extension-classes in the typo3/
directory. All existing classes that do not follow the pattern will be
renamed and then just subclass the T3_ class. Example (from the top of
my head)

New class (in a new file):
  T3_BrowseLinks_FolderTree extends t3lib_foldertree
Existing class
  localfoldertree extends T3_BrowseLinks_FolderTree {}
with a deprecation log message in the constructor and a call to
parent::construct().

Other class names
 * T3_Bootstrap
 * T3_Ajax
 * T3_Clickmenu
 * T3_Module_Document_Edit (alt_doc.php)
 * T3_Module_Backend (backend.php)
 * T3_CommandLine_ReferenceIndex


The strict divide is this: Everything generic goes to t3lib/, everything
that is basic setup and tools for the TYPO3 Backend goes to typo3/,
everything else goes to system extensions.


Discussion C: Namespaces
In case you were wondering why I wasn't talking about namespaces: I
actually read an article about namespaces that it is quite complicated
accessing global functions when within a namespace. So I don't know yet
about namespaces and how much they'd break in the existing Core.


All the best,
Benni.

PS: Hail to the community manager - it's June 21st :)


More information about the TYPO3-team-core mailing list