1

从 TYPO3 11 LTS 开始,typo3二进制文件不再位于其中sysext/core/bin/,至少不在作曲家模式下,所以我需要找到一种新方法来bin-dir在作曲家模式下找到来自作曲家的位置。

我应该使用 composer/composer 包来解析它吗?我需要root作曲家,而不是 TYPO3 Crawler 的作曲家。

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

关于如何处理这个问题的任何建议?一个选项可能是将其添加为设置,因此它是扩展设置的一部分。

4

1 回答 1

2

我去了这个解决方案。但很高兴听到其他/更好的解决方案。

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 . '/';
}

这是调度程序扩展的 TYPO3 核心中的实现。

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

于 2021-10-17T17:08:47.883 回答