[TYPO3-core] RFC #12067: Remove ext_autoload.php files for extensions using Extbase naming convention

Rupert Germann rupi at gmx.li
Sat Sep 26 15:04:26 CEST 2009


hi Xavier,

I'd say this change is not needed at all.
there's exactly one extension which needs ext_autoload.php: extbase
all other extbase based extensions are involved by the extbase 
dispatcher which registers the name based autoloader.

try it by deleting ext_autoload.php from the blog example: all works as 
before.

here's a debug trail from an extbase autoloader call (without 
ext_autoload.php):

Tx_Extbase_Dispatcher->initializeConfigurationManagerAndFrameworkConfiguration#96 
t3lib_div::makeInstance#151
t3lib_div::getClassName#4921
class_exists#4971
spl_autoload_call#
t3lib_autoloader::autoload#
t3lib_div::requireFile#107
require#5053
spl_autoload_call#35
Tx_Extbase_Utility_ClassLoader::loadClass#

you see the make instance call first hits the core autoloader where it 
fails to find the file in the registry. Then it tries to find an 
ext_autoload.php file to extend the registry which fails too.
After this it hits the second autoloader from the autoloader stack which 
is located in  extbase. This autoloader knows how to get a filename from 
a classname and so the file is finally found.

all works, no change needed.

greets
rupert


Xavier Perseguers schrieb:
> Hi,
> 
>> This is a SVN patch request
>>
>> Type: Feature/Enhancement
>>
>> Branches: trunk only
>>
>> Bugtracker reference:
>> http://bugs.typo3.org/view.php?id=12067
>>
>> Problem:
>> The use of ext_autoload.php files was once supposed to be used only 
>> for old-fashioned extensions that did not used Extbase naming 
>> convention (Classes directory, class component parts as subdirectories).
>>
>> Nowadays, all new extensions (starting with Extbase itself) are 
>> polluted with a never-ending growing ext_autoload.php file and we 
>> slowly start adding all our classes there to be sure all will work 
>> fine without exactly knowing what really needs to be in.
>>
>> The patch allows not less than the removal of the ext_autoload.php 
>> file for all extensions sticking to using only the Extbase naming 
>> convention. This file may still be used for some third-party classes 
>> that may be included in a pure Extbase-styled extension.
>>
>> Note 1: This has nothing to do with extensions relying on Extbase 
>> itself, only on its naming convention.
>> Note 2: Fine-tuning of style and the rest may apply
>>
>> How-to test:
>> e.g., delete file EXT:extbase/ext_autoload.php and see that it still 
>> works
> 
> Thanks to Sebastian (on the MVC list), I discovered that Extbase already 
> has its own naming-convention autoloader
> 
> [quoting Sebastian]
>  > in fact, extbase has such an autoloader already in place. Have a look
>  > into Utility/Autoloader (I think).
>  > It is registered in the Dispatcher in the constructor method. And
>  > actually I feel that this is the wrong place for it, as the automatic
>  > resolving only works when the dispatcher is actually called.
>  >
>  > So, I'd suggest that we should find a more clever place to include the
>  > autoloader instead of the Dispatcher :-)
> [/quoting Sebastian]
> 
> Here is v2 which basically does the same as v1 but using similar code 
> taken from Extbase that was then de-Extbased to fit into Core without 
> dependency. Concerning code in Extbase, it's probable that it won't be 
> needed anymore once this found its way to Core, meaning Extbase will be 
> able to be even more clean.
> 
> One side-note concerning nitpicking: Core's autoloader declares its 
> methods with "static protected" while the rest of Core and Extbase uses 
> "protected static" which I find much better. Please find enclosed 
> another patch to clean this up once my patch has been committed.
> 
> Regards
> 
> References:
> - 12067_v2.diff : new version of the RFC patch that uses "same" code as 
> Extbase
> - autoloader_cleanup.diff : replaces "static protected" by "protected 
> static", adds missing 's' in comments, removes last empty line
> - thread in MVC list: "Fluid validation: how to debug errors?"
> 


More information about the TYPO3-team-core mailing list