A PSR-11 compatible service provider that registers a fully functional set of PSR-17 and PSR-7 HTTP factories using Nyholm PSR-7 and Nyholm ServerRequestCreator.
Designed to work out of the box with the php-fast-forward/container autowiring system.
composer require fast-forward/http-factory- Registers the Psr17Factory as the base implementation for all PSR-17 interfaces
- Registers the ServerRequestCreator using InvokableFactory
- Provides ServerRequestInterface::class using fromGlobals() via MethodFactory
- Aliases:
- RequestFactoryInterface
- ResponseFactoryInterface
- ServerRequestFactoryInterface
- StreamFactoryInterface
- UploadedFileFactoryInterface
- UriFactoryInterface
 
If you’re using fast-forward/container:
use FastForward\Container\container;
use FastForward\Config\ArrayConfig;
use FastForward\Container\ContainerInterface;
$config = new ArrayConfig([
    ContainerInterface::class => [
        // Reference the service provider by class name
        HttpMessageFactoryServiceProvider::class,
    ],
]);
$container = container($config);
$requestFactory = $container->get(Psr\Http\Message\RequestFactoryInterface::class);
$serverRequest = $container->get(Psr\Http\Message\ServerRequestInterface::class);The following services will be automatically registered in your container when using HttpMessageFactoryServiceProvider:
| Service Interface | Implementation Source | 
|---|---|
| Psr\Http\Message\RequestFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Psr\Http\Message\ResponseFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Psr\Http\Message\ServerRequestFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Psr\Http\Message\StreamFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Psr\Http\Message\UploadedFileFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Psr\Http\Message\UriFactoryInterface | Nyholm\Psr7\Factory\Psr17Factory(via alias) | 
| Nyholm\Psr7\Factory\Psr17Factory | Registered via InvokableFactory | 
| Nyholm\Psr7Server\ServerRequestCreator | Registered via InvokableFactory, with dependencies | 
| Psr\Http\Message\ServerRequestInterface | Created by calling fromGlobals()onServerRequestCreatorviaMethodFactory | 
This package is open-source software licensed under the MIT License.
Contributions, issues, and feature requests are welcome!
Feel free to open a GitHub Issue or submit a Pull Request.