Tomasnorre
Tomasnorre

Reputation: 413

How to locate TYPO3 Binary (typo3)

As of TYPO3 11 LTS the typo3 binary isn't located in sysext/core/bin/ anymore, at least not in composer mode, so I need to get a new way to locate the bin-dir from composer in composer mode.

Should I use the composer/composer package to parse that? I need the root composer and not the one for the TYPO3 Crawler.

if (TYPO3_COMPOSER_MODE) {
    // How to find the composer-bin dir?      
} else {
    $typo3BinaryPath = ExtensionManagementUtility::extPath('core') . 'bin/';
}

Any suggestions on how to deal with this? An option could be to add it as a setting, so it's part of the extension settings.

Upvotes: 0

Views: 299

Answers (1)

Tomasnorre
Tomasnorre

Reputation: 413

I went for this solution. But would be happy to hear about other/better solutions.

private function getComposerBinPath(): string
{
    $composerRootPath = Environment::getComposerRootPath();
    $composerJson = json_decode(file_get_contents($composerRootPath . '/composer.json'), true);
    $binDir = $composerJson['config']['bin-dir'] ?? 'vendor/bin';
    return $composerRootPath . '/' . $binDir . '/';
}

This is the implementation in the TYPO3 Core for the Scheduler extension.

https://github.com/TYPO3/typo3/blob/8a9c80b9d85ef986f5f369f1744fc26a6b607dda/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php#L402

Upvotes: 3

Related Questions