简体   繁体   English

如何定位 TYPO3 二进制 (typo3)

[英]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.从 TYPO3 11 LTS 开始, typo3二进制文件不再位于sysext/core/bin/ ,至少不在作曲家模式下,所以我需要一种新的方法来在作曲家模式下从作曲家中找到bin-dir

Should I use the composer/composer package to parse that?我应该使用 composer/composer 包来解析它吗? I need the root composer and not the one for the TYPO3 Crawler.我需要root作曲家而不是 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.一种选择是将其添加为设置,因此它是扩展设置的一部分。

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.这是调度程序扩展在 TYPO3 核心中的实现。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM