我在没有 Composer 的情况下运行了 TYPO3 v10.2。我正在创建一个扩展并希望将一些第三方 PHP 库包含到我的 Extbase 扩展中。我已经在 TYPO3 文档中阅读了那些应该放在其中的文档,Resources/Private/PHP/ThirdPartyLibrary但是我如何将它们包含在其中?是否仍然可以composer require或我应该只下载第三方库资源并在那里解压缩?如何在控制器或扩展中使用来自外部库的命名空间/类?没有 AND 与 composer 做到这一点的最佳方法是什么?想知道这两种方式。到目前为止,谢谢!
composer initcomposer req <neded packages>composer uvendor/到你的your_extension/Resources/Private/PHP/ThirdPartyLibrary/vendor/您刚刚移动的路径。他们把外部图书馆放在 Resources/Private/Shariff/vendor/
https://bitbucket.org/reelworx/rx_shariff/src/master/Resources/Private/Shariff/
https://bitbucket.org/reelworx/rx_shariff/src/master/Classes/Shariff.php
如果你想在你的控制器中使用它们,这些库需要已经有命名空间。
由于您在 TYPO3 V10 中,您现在可以使用在 TYPO3 中实现的新 symfony 依赖注入:https : //usetypo3.com/dependency-injection.html
your_extension/Classes/Controller/YourController.php
/**
* @var ThirdPartyLibrary
*/
protected $thirdPartyLibrary;
/**
* @param ThirdPartyLibrary $thirdPartyLibrary
*/
public function __construct(ThirdPartyLibrary $thirdPartyLibrary)
{
$this->thirdPartyLibrary = $thirdPartyLibrary;
}
Run Code Online (Sandbox Code Playgroud)
your_extension/Configuration/Services.yaml
services:
_defaults:
autowire: true
autoconfigure: true
public: false
Vendor\Namespace\:
resource: '../Resources/Private/PHP/ThirdPartyLibrary/*'
Run Code Online (Sandbox Code Playgroud)