Every TYPO3 developer knows that moment: you're diving into an existing project and need to quickly understand what you're working with. Is it running TYPO3 v11, v12 or v13? Is it using Composer mode? Where exactly is the site root? These fundamental questions need answers before you can start productive work.
In this comprehensive guide, we'll explore the various methods to check your TYPO3 version, determine if the installation uses Composer, and locate the site root across different TYPO3 versions. Whether you're troubleshooting, developing extensions, or performing an upgrade, these techniques will save you valuable time and help prevent compatibility issues.
What is TYPO3 Version?
A TYPO3 version refers to the specific release number of the TYPO3 CMS you’re using. Each version comes with its own set of features, performance improvements, security updates, and compatibility requirements.
TYPO3 uses a versioning format like v12 LTS or v13.1, where:
- The number indicates the major or minor release
- LTS stands for Long-Term Support, offering extended updates for up to 3 years
Why Version Checking Matters
Before diving into the code, let's understand why checking the TYPO3 version is crucial:
- Compatibility: Extensions and custom code may only work with specific TYPO3 versions
- Security: Older versions might have known vulnerabilities
- Feature availability: Newer versions offer additional functionality
- Upgrade planning: Knowing your current version is essential for planning migrations
5 Best Methods to Check Your TYPO3 Version
Method 1: Using the Admin Panel
The simplest way to check your TYPO3 version is through the TYPO3 backend:
- Log in to the TYPO3 backend
- Look at the bottom of the page where the version number is displayed
- For more details, go to the System → Help → About module
Note: This method requires backend access and doesn't help when you need programmatic access to version information.
Method 2: Using PHP Code (TYPO3 v11+)
For TYPO3 v11 and newer, the recommended approach uses the TYPO3Version class:
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Information\Typo3Version;
// Get version information object
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
// Get major version (e.g., "11" from "11.5.0")
$majorVersion = $versionInformation->getMajorVersion();
// Get branch (e.g., "11.5")
$branch = $versionInformation::BRANCH;
// Get full version (e.g., "11.5.0")
$fullVersion = $versionInformation::VERSION;
// Output the information
echo "TYPO3 Major Version: " . $majorVersion . PHP_EOL;
echo "TYPO3 Branch: " . $branch . PHP_EOL;
echo "TYPO3 Full Version: " . $fullVersion . PHP_EOL;
Method 3: Using Constants (TYPO3 v11 and older)
In TYPO3 v11 and earlier versions, you can also use constants:
// The TYPO3 branch (e.g., "11.5")
echo "TYPO3 Branch: " . TYPO3_branch . PHP_EOL;
// The full TYPO3 version (e.g., "11.5.0")
echo "TYPO3 Version: " . TYPO3_version . PHP_EOL;
Pro Tip: When writing version-compatible code, always use version_compare() instead of direct comparisons. For example: version_compare(TYPO3_branch, '12.0', '>=') to check if the TYPO3 version is 12.0 or higher.
Method 4: Command Line Interface (CLI)
If you have terminal access to your TYPO3 instance, you can use the CLI:
# For TYPO3 v9+
./vendor/bin/typo3 --version
# For TYPO3 v8 and earlier
./typo3/cli_dispatch.phpsh extbase version:show
How to Detect Composer Mode in TYPO3
Why Composer Mode Matters
TYPO3 can be installed either traditionally or using Composer. Knowing which installation method is used affects:
- Extension installation workflows
- File paths and directory structures
- Update and maintenance procedures
- Dependency management
3 Methods to Check Composer Mode in TYPO3
Method 1: File System Structure
A quick visual check:
- If there's a composer.json file in the project root and vendor directory, it's likely using Composer
- Traditional installations have most files directly in the web root
Method 2: Using PHP Code (TYPO3 v9+)
For TYPO3 v9 and newer versions:
- use TYPO3\CMS\Core\Core\Environment;
$isComposerMode = Environment::isComposerMode();
echo "Is Composer Mode: " . ($isComposerMode ? 'Yes' : 'No');
Method 3: Using PHP Code (TYPO3 v8 and earlier)
For older TYPO3 versions:
use TYPO3\CMS\Core\Core\Bootstrap;
$isComposerMode = Bootstrap::usesComposerClassLoading();
echo "Is Composer Mode: " . ($isComposerMode ? 'Yes' : 'No');
Locating the TYPO3 Site Root
Understanding Site Root in Different Contexts
The site root in TYPO3 can refer to:
1. Public web root - where publicly accessible files are stored
2. Project root - where the entire TYPO3 project is located (especially important in Composer installations)
Methods to Determine Site Root
Method 1: Using Environment Class (TYPO3 v9+)
For TYPO3 v9 and newer:
use TYPO3\CMS\Core\Core\Environment;
// Get the public web root
$publicPath = Environment::getPublicPath();
echo "Public Path: " . $publicPath . PHP_EOL;
// Get the project root (important for Composer mode)
$projectPath = Environment::getProjectPath();
echo "Project Path: " . $projectPath . PHP_EOL;
Method 2: Using PATH Constants (TYPO3 v8 and earlier)
For TYPO3 v8 and earlier:
// The web root path
echo "Site Root: " . PATH_site . PHP_EOL;
Method 3: Full Implementation Across Versions
This code handles both checking for Composer mode and determining site roots across different TYPO3 versions:
// Check composer/non-composer mode and site root across versions
if (version_compare(TYPO3_branch, '9.0', '>')) {
// TYPO3 v9 and later
$siteRoot = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/';
$composerSiteRoot = \TYPO3\CMS\Core\Core\Environment::getProjectPath() . '/';
$isComposerMode = \TYPO3\CMS\Core\Core\Environment::isComposerMode();
} else {
// TYPO3 v8 and earlier
$siteRoot = PATH_site;
$isComposerMode = \TYPO3\CMS\Core\Core\Bootstrap::usesComposerClassLoading();
if ($isComposerMode) {
$commonEnd = explode('/', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'));
unset($commonEnd[count($commonEnd) - 1]);
$composerSiteRoot = implode('/', $commonEnd) . '/';
}
}
echo "Site Root: " . $siteRoot . PHP_EOL;
echo "Is Composer Mode: " . ($isComposerMode ? 'Yes' : 'No') . PHP_EOL;
if ($isComposerMode) {
echo "Composer Site Root: " . $composerSiteRoot . PHP_EOL;
}
Version-Specific Considerations
TYPO3 v13 Specifics
TYPO3 v13 (released in 2023) continues to use the same APIs for version checking as v12, but has some important changes:
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Information\Typo3Version;
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
echo "TYPO3 v13 Version: " . $versionInformation::VERSION;
// Additional v13-specific environment check
$isDevMode = Environment::getContext()->isDevelopment();
echo "Is Development Mode: " . ($isDevMode ? 'Yes' : 'No');
Pro Tip: In TYPO3 v13, many legacy methods have been removed. Always check the official migration guide when updating your code.
TYPO3 v12 Specifics
TYPO3 v12 introduced some refinements to the Environment class:
- use TYPO3\CMS\Core\Core\Environment;
// Check for container usage (Docker/Kubernetes) - new in v12
$containerized = Environment::isRunningInContainer();
echo "Running in Container: " . ($containerized ? 'Yes' : 'No');
// Get application context
$context = Environment::getContext();
echo "Application Context: " . $context;
TYPO3 v11 Specifics
TYPO3 v11 fully embraced the Environment class, but still supported some legacy methods:
- use TYPO3\CMS\Core\Core\Environment;
// Get the var path (for caches, logs, etc.)
$varPath = Environment::getVarPath();
echo "Var Path: " . $varPath . PHP_EOL;
// Check if running on Windows
$isWindows = Environment::isWindows();
echo "Is Windows: " . ($isWindows ? 'Yes' : 'No') . PHP_EOL;
Checking Extbase Classes in TYPO3
When working with Extbase in TYPO3, you might need to check the availability of specific classes. Here's how to do it:
Method 1: Class Existence Check
// Check if an Extbase class exists
$extbaseClassExists = class_exists('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController');
echo "Extbase Action Controller exists: " . ($extbaseClassExists ? 'Yes' : 'No');
Method 2: Using Extension Manager
You can also check if the Extbase extension is loaded:
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
$extbaseLoaded = ExtensionManagementUtility::isLoaded('extbase');
echo "Extbase extension loaded: " . ($extbaseLoaded ? 'Yes' : 'No');
Method 3: Reflection for Class Details
For more detailed inspection of Extbase classes:
use TYPO3\CMS\Core\Utility\GeneralUtility;
if (class_exists('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService')) {
$reflectionService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
// Example: Check if a specific class has a certain method
$hasMethod = $reflectionService->hasMethod(
'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference',
'getOriginalResource'
);
echo "FileReference has getOriginalResource method: " . ($hasMethod ? 'Yes' : 'No');
}
Best Practices and Common Pitfalls
Best Practices
- Version Compatibility: Always use version checks when writing code that needs to work across multiple TYPO3 versions
- Path Handling: Use Environment class methods instead of hardcoded paths
- Error Handling: Add proper error handling for version-specific code paths
- Documentation: Comment your version-specific code thoroughly for future maintainers
Common Pitfalls
- Direct Comparison: Avoid direct string comparison of versions (TYPO3_branch == '12.4'). Use version_compare() instead.
- Hardcoded Paths: Don't hardcode paths that might differ between Composer and non-Composer installations
- Deprecated Methods: Be aware of deprecated methods that might be removed in future versions
Note - Always test your code on all targeted TYPO3 versions. What works in v11 might not work in v12 or v13.
Conclusion
Understanding how to check TYPO3 version, composer mode, and site root is essential knowledge for every TYPO3 developer. These checks form the foundation of compatibility-aware code and help prevent issues when working across multiple TYPO3 installation.
By using the methods outlined in this guide, you'll be able to confidently work with any TYPO3 version from v11 to v13, whether it's using Composer or traditional installation. Remember to always use version-appropriate methods and properly handle different scenarios in your code.
For more advanced TYPO3 development techniques and best practices, subscribe to our newsletter or follow our blog for regular updates. Happy coding!
Sanjay Chauhan
CTO at T3Planet & NITSANSanjay Chauhan, Co-Founder of NITSAN (Award winning TYPO3 agency) and Pioneer of T3Planet (first-ever TYPO3 Shop). A true TYPO3 fanatic since 2010. I bring strong TYPO3 experience in building customer-business…
More From Author