if(\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('10.4')) { // TYPO3 10.4 installed } else { // TYPO3 version incompatible }
$packageName = 'typo3/cms-fluid'; if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('9.5')) { $packageLibrary = new \TYPO3\CMS\Core\Package\PackageLibrary(); $package = $packageLibrary->getPackage($packageName); } else { $package = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($packageName); }In this example, the compat_version method is used to check the system compatibility of the TYPO3 installation. If the system is compatible with TYPO3 version 9.5 or above, then the PackageLibrary class is used to determine the package library for the given package name. If the system is not compatible with TYPO3 version 9.5 or above, then the extPath method of the ExtensionManagementUtility class is used to determine the package library. The package library contains the package information such as extension path, namespace, etc.