[TYPO3-v4] autoloader and path

Steffen Gebert steffen at steffen-gebert.de
Tue Jan 4 15:37:51 CET 2011


> $extensionPath = t3lib_extMgm::extPath(extkey);
>
> As the autoloader reads this file and expects an array, this file should
> be cheap. Imagine 100 requests to autoloader with makeInstance. This
> would be 100 times calling t3lib_extMgm::extPath. Even this function is
> static and small, this can be prevented by using

If I don't interpret the code wrong, it's only read one time:
attemptToLoadRegistryForGivenClassName():
> $possibleAutoloadConfigurationFileName = t3lib_extMgm::extPath($extensionKey) . 'ext_autoload.php';
> if (file_exists($possibleAutoloadConfigurationFileName)) {
> 	self::$extensionHasAutoloadConfiguration[$extensionKey] = TRUE;
> 	$extensionClassNameToFileMapping = require($possibleAutoloadConfigurationFileName);
> 	self::$classNameToFileMapping = array_merge($extensionClassNameToFileMapping, self::$classNameToFileMapping);
> } else {
> 	self::$extensionHasAutoloadConfiguration[$extensionKey] = FALSE;
> }

Afterwards, the file will never be included.

> $extensionPath = dirname(__FILE__);
>
> I suggest to use this pattern instead which makes it a lot faster.
> Your opinion?
Nevertheless, dirname(__FILE__) sounds reasonable.

Kind regards
Steffen

-- 
Steffen Gebert
TYPO3 Core Team Member

Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/


More information about the TYPO3-project-v4 mailing list