https://github.com/php-fast-forward/http-factory
Fast Forward PSR-7 HTTP Factory utility classes
https://github.com/php-fast-forward/http-factory
http-factory php php-library psr-7 service-provider
Last synced: 5 months ago
JSON representation
Fast Forward PSR-7 HTTP Factory utility classes
- Host: GitHub
- URL: https://github.com/php-fast-forward/http-factory
- Owner: php-fast-forward
- License: mit
- Created: 2025-05-06T22:13:33.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-05-06T22:19:32.000Z (5 months ago)
- Last Synced: 2025-05-06T23:24:33.303Z (5 months ago)
- Topics: http-factory, php, php-library, psr-7, service-provider
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π FastForward HTTP Factory
[](https://www.php.net/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/php-fast-forward/http-factory/actions)A [PSR-11](https://www.php-fig.org/psr/psr-11/) compatible service provider that registers a fully functional set of [PSR-17](https://www.php-fig.org/psr/psr-17/) and [PSR-7](https://www.php-fig.org/psr/psr-7/) HTTP factories using [Nyholm PSR-7](https://github.com/Nyholm/psr7) and [Nyholm ServerRequestCreator](https://github.com/Nyholm/psr7-server).
Designed to work out of the box with the [`php-fast-forward/container`](https://github.com/php-fast-forward/container) autowiring system.
---
## π¦ Installation
```bash
composer require fast-forward/http-factory
```## β Features
- 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## π οΈ Usage
If youβre using `fast-forward/container`:
```php
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);
```## π§ Services Registered
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()` on `ServerRequestCreator` via `MethodFactory` |---
## π License
This package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT).
---
## π€ Contributing
Contributions, issues, and feature requests are welcome!
Feel free to open a [GitHub Issue](https://github.com/php-fast-forward/http-factory/issues) or submit a Pull Request.