5 Ways to Check TYPO3 Version, Composer Mode & Site Root

5 Ways to Check TYPO3 Version, Composer Mode & Site Root

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, v13, or even the latest v14? 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, working with a TYPO3 Template, or performing an upgrade, these techniques will save you valuable time and help prevent compatibility issues.

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

To ensure your system stays current, you can use a Version Checker to quickly identify your current TYPO3 version and support status.

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

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');

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;
}

TYPO3 v14 Specifics

TYPO3 v14 (LTS, released in 2026) continues the modern API approach introduced in v12 and v13, with further cleanup of legacy code and a stronger focus on Composer-based setups and PHP 8.2+.

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Core\Environment;

// Get TYPO3 version info
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);

echo "TYPO3 v14 Version: " . $versionInformation::VERSION;

// Environment-based checks (standard approach)
$context = Environment::getContext();
$isDevMode = $context->isDevelopment();

echo "Application Context: " . $context;
echo "Is Development Mode: " . ($isDevMode ? 'Yes' : 'No');

// Get paths (Composer-friendly structure)
$projectPath = Environment::getProjectPath();
$publicPath = Environment::getPublicPath();

echo "Project Path: " . $projectPath;
echo "Public Path: " . $publicPath;

What’s Important in TYPO3 v14

  • PHP 8.2+ is required (modern baseline)
  • Environment API is standard for paths, context, and system checks
  • Composer-first approach is now the norm (non-Composer setups are rare)
  • Further removal of deprecated / legacy APIs from older versions
  • Improved consistency across v12 → v14 (easier upgrades)

Pro Tip:

  • In TYPO3 v14, always rely on the Typo3Version class and Environment API..
  • Avoid legacy constants like TYPO3_version or TYPO3_branch, as they are deprecated and may not work reliably in modern setups.

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;

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

  • 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 across all targeted TYPO3 versions (v11–v14). Even minor upgrades can introduce breaking changes, especially from v12 onward, where legacy APIs are removed and modern standards (like the Environment API and Composer-based setups) are enforced. 

Understanding how to check the TYPO3 version, Composer mode, and site root is essential for every TYPO3 developer. These checks form the foundation of compatibility-aware code and help prevent issues when working across different TYPO3 installations.

By using the methods outlined in this guide, you can confidently work with TYPO3 versions from v11 to v14, whether the project uses Composer or a traditional setup. As TYPO3 continues to evolve, especially from v12 onward, it’s important to rely on modern APIs like the Typo3Version class and the Environment API for consistent and future-proof development.

Always use version-appropriate methods, handle edge cases carefully, and test your code across all targeted versions to avoid unexpected issues.

For more advanced TYPO3 development techniques and best practices, follow our blog or subscribe to stay updated with the latest TYPO3 trends and updates. Happy coding!

Your One-Stop Solutions for Custom TYPO3 Development

  • A Decade of TYPO3 Industry Experience
  • 350+ Successful TYPO3 Projects
  • 87% Repeat TYPO3 Customers
TYPO3 Service
wolfgang weber

Post a Comment

×