Get extension paths

How to get absolute and relative paths of an extension.

  • 6 LTS
  • 7 LTS
  • 8 LTS
  • 9 LTS
  • 10-dev

Get absolute path

To get the absolute path of a extension, you can use the following Method of the ExtensionManagementUtility provided by core:

 

ExtensionManagementUtility::extPath('name_of_extension');

 

 

Get relative path

The following way is deprecated since TYPO3 8:

 

ExtensionManagementUtility::extRelPath('name_of_extension');

 

Inside TCA you can simply use a string like:

 

EXT:name_of_extension/...

 

Otherwise you should go this way:

 

ExtensionManagementUtility::siteRelPath('name_of_extension')

 

Or using the PathUtlity combined with ExtensionManagementUtility:

 

PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::extPath('name_of_extension'));

 

 

Include ExtensionManagementUtility

DonĀ“t forget to include the class of the ExtensionManagementUtility:

 

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

 

And please include it outside of your class ;)