[TYPO3-core] Feature #9633: Implement autoloading for TYPO3

Martin Kutschker masi-no at spam-typo3.org
Sun Apr 26 18:49:45 CEST 2009


Sebastian KurfŸürst schrieb:
> This is an SVN patch request.
> 
> Type: Feature
> 
> BT Reference: http://bugs.typo3.org/view.php?id=9633
> 
> Branch: trunk
> 
> Problem:
> Currently, lots of files get included at each request, without being
> needed at all (Example: Caching framework). To get rid of this problem,
> we're introducing the new autoloader here.
> 
> Solution:

Any reason isn particular why you didn't want to use the autloader
Dmitry wrote and I have worked on later? It uses a caching method of
class names and doesn't need any rewriting of existing code.

Though I'm for cleaning up class names and files in t3lib, typo3/classes
and tslib. So autoloader or not, I'm glad if we could have three patches
that make these changes for the sake of consistency.

> Thus, the autoloader is divided into two parts:
> 1) If the class which should be loaded starts with Tx_ (the backported
> naming convention from FLOW3), we can use a very simple autoloader
> because of the rigid conventions (implemented in
> t3lib_autoloader::getClassPathByDirectoryStructure).

I agree with Dmitry that we should stick to tx_ in lower case. It looks
alien in v4. But it's not so simple as that. We have t3lib (easy to
handle), we have tslib (another easy exemption), we have the files in
typo3/classes (I suggest to rename the classes typo3_ClassName). So far
so good. That an extension class has to start with tx_ is not true, but
in v4 the prefix user_ is also valid. And it doesn't tell you anything
of the position within the extension (but you have dealt with this).

Furthermore Ingo pointed out that the extensions foo_bar and foobar
share the same extension key foobar. I couldn't think of resolving this
issue.

> 2) For classical extensions and the TYPO3 core, we use the "registry"
> concept which is basically an associative array mapping from class names
> to fully qualified file names.
> Every "classical" extension wanting to use the autoloader needs to ship
> a file called ext_autoload.php in its root directory (can be
> autogenerated with extdeveval). The core ships such a file as well,
> located in t3lib/core_autoload.php.
> When the autoloader is started, the core files are automatically added
> to the registry by loading the t3lib/core_autoload.php file.
> ext_autoload.php files are loaded on demand when needed.

No need to do this, the autoloader patch mentioned has a PHP parser
(Dmitry's original uses a regexp, mine uses PHP's tokenizer) to extract
the class names (which worked fast and well in my tests).

> We implemented a new extdeveval module to do this.

Hm, I don' think it belongs to a module. It must be part of the real
Core, so it can be generated any time. extdeveval shouldn't become
necessary to run TYPO3.

> This patch is part of a patch series to implement the autoloader. The
> patches have been worked out together with Olly, based on work by
> Dmitry, Ingo, Ingmar, Masi and Jochen.

Oh my, Jochen also spent time on this?

Masi

PS: Thanx for taking care of the issue. I didn't find the time and
energy to present my original patch which IMHO only lacked the enforcing
of the naming schemes in extension classes to
avoid problems with duplicate class names.


More information about the TYPO3-team-core mailing list