bnf / typo3-http-factory
TYPO3 PSR-7 实现的 PSR-17 HTTP 消息工厂
0.1.2
2020-09-02 11:54 UTC
Requires
- php: ^7.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- typo3/cms-core: ^8.7 || ^9.5 || ^10.4
Requires (Dev)
- php: ^7.2
- php-coveralls/php-coveralls: ^2.1
- phpspec/prophecy: ^1.8
- phpstan/phpstan: ^0.11.15
- phpstan/phpstan-strict-rules: ^0.11.1
- phpunit/phpunit: ^8.3
- squizlabs/php_codesniffer: ^3.4
Provides
This package is auto-updated.
Last update: 2024-08-29 05:18:32 UTC
README
已废弃
截至 TYPO3 v10.2,此包不再需要,因为工厂已被 合并 到 TYPO3 核心中。
安装
要使用此包,请使用 Composer 安装 bnf/typo3-http-factory
composer require bnf/typo3-http-factory
注意,这是一个 纯 Composer 包 - 不是一个完整的 TYPO3 扩展。此包旨在被其他 TYPO3 扩展(如 bnf/slim-typo3)包装,以便在 PSR-7/PSR-15 请求处理器上下文中提供 PSR-17 工厂。
在自定义包装扩展中的使用
如果您想在自定义的 TYPO3 扩展中包装此包,您需要指定 TYPO3 依赖注入容器的接口映射。
对于 TYPO3 v8/v9,您可以在 ext_localconf.php
中提供 Extbase ObjectManager 的配置
$container = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
$container->registerImplementation(\Psr\Http\Message\RequestFactoryInterface::class, \Bnf\Typo3HttpFactory\RequestFactory::class);
$container->registerImplementation(\Psr\Http\Message\ResponseFactoryInterface::class, \Bnf\Typo3HttpFactory\ResponseFactory::class);
$container->registerImplementation(\Psr\Http\Message\ServerRequestFactoryInterface::class, \Bnf\Typo3HttpFactory\ServerRequestFactory::class);
$container->registerImplementation(\Psr\Http\Message\StreamFactoryInterface::class, \Bnf\Typo3HttpFactory\StreamFactory::class);
$container->registerImplementation(\Psr\Http\Message\UploadedFileFactoryInterface::class, \Bnf\Typo3HttpFactory\UploadedFileFactory::class);
$container->registerImplementation(\Psr\Http\Message\UriFactoryInterface::class, \Bnf\Typo3HttpFactory\UriFactory::class);
unset($container);
从 TYPO3 v10.0 开始,您可以在扩展依赖注入配置 Configuration/Services.yaml
中配置别名映射
Psr\Http\Message\RequestFactoryInterface:
alias: Bnf\Typo3HttpFactory\RequestFactory
Psr\Http\Message\ResponseFactoryInterface:
alias: Bnf\Typo3HttpFactory\ResponseFactory
Psr\Http\Message\ServerRequestFactoryInterface:
alias: Bnf\Typo3HttpFactory\ServerRequestFactory
Psr\Http\Message\StreamFactoryInterface:
alias: Bnf\Typo3HttpFactory\StreamFactory
Psr\Http\Message\UploadedFileFactoryInterface:
alias: Bnf\Typo3HttpFactory\UploadedFileFactory
Psr\Http\Message\UriFactoryInterface:
alias: Bnf\Typo3HttpFactory\UriFactory