$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('my_extension'); $extRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('my_extension'); echo $extPath; // output: /var/www/typo3conf/ext/my_extension/ echo $extRelPath; // output: /typo3conf/ext/my_extension/
$extRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('my_extension'); $myImage = $extRelPath . 'Resources/Public/Images/my_image.png'; echo '';In this example, we use the extRelPath method to get the relative path of the 'my_extension' extension, and then append the path to an image file within the extension. This allows us to easily reference files within the extension without hardcoding absolute paths. The package library for this class would be the TYPO3 CMS core utility.