[TYPO3-english] How does the autoload feature work?

Christian Kuhn lolli at schwarzbu.ch
Fri Nov 5 01:46:13 CET 2010


On 11/05/2010 12:49 AM, Philippe Moreau wrote:
> Has anyone managed to get the new autoload feature to work in an extension?

Sure, we use it in every new extension: No need to think about 
require_once() anymore ;)

> I have added the necessary ext_autoload.php file, but it seems like it isn't
> enough. I can't figure out what else I'm supposed to do and there is no
> documentation anywhere. If someone could help me with this it would help a
> lot!

Say you have a class called tx_myext_MyClass located in 

$extensionPath = t3lib_extMgm::extPath('myext');
return array(
	'tx_myext_myclass' => $extensionPath .

- t3lib_div::makeInstance('tx_myext_MyClass', constructor param1, 
constructor param2, ...);
- static calls work, too

ext_autoload constraints:
- always lowercase the classname (key part of the array) in ext_autoload
- classnames must start with tx_ (or probably ux_)
- always locate ext_autoload.php within your extension root (next to 
ext_tables.sql and friends)
- make sure your extension is loaded, TYPO3 will find the file itself, 
no need to annotate it somewhere


More information about the TYPO3-english mailing list