|
| 1 | +🚀 FastForward HTTP Client |
| 2 | + |
| 3 | +[](https://www.php.net/) |
| 4 | +[](https://opensource.org/licenses/MIT) |
| 5 | +[](https://github.com/php-fast-forward/http-client/actions) |
| 6 | + |
| 7 | +A [PSR-11](https://www.php-fig.org/psr/psr-11/) compatible service provider that registers a fully functional set of [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client using Symfony HttpClient and Psr18Client. |
| 8 | + |
| 9 | +Designed to work out of the box with the [`php-fast-forward/container`](https://github.com/php-fast-forward/container) autowiring system. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## 📦 Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +composer require fast-forward/http-client |
| 17 | +``` |
| 18 | + |
| 19 | +## ✅ Features |
| 20 | +- Registers the default _Symfony HttpClient_ using `HttpClient::create() |
| 21 | +- Registers the PSR-18 _Psr18Client_ with its dependencies injected |
| 22 | +- Provides aliases for: |
| 23 | + - _Psr\Http\Client\ClientInterface_ |
| 24 | + - _Symfony\Component\HttpClient\HttpClient_ |
| 25 | + |
| 26 | +## 🛠️ Usage |
| 27 | + |
| 28 | +If you’re using `fast-forward/container`: |
| 29 | +```php |
| 30 | +use FastForward\Container\container; |
| 31 | +use FastForward\Config\ArrayConfig; |
| 32 | +use FastForward\Container\ContainerInterface; |
| 33 | + |
| 34 | +$config = new ArrayConfig([ |
| 35 | + ContainerInterface::class => [ |
| 36 | + // Reference the service provider by class name |
| 37 | + FastForward\Http\Client\ServiceProvider\HttpClientServiceProvider::class, |
| 38 | + ], |
| 39 | +]); |
| 40 | + |
| 41 | +$container = container($config); |
| 42 | + |
| 43 | +$client = $container->get(Psr\Http\Client\ClientInterface::class); |
| 44 | +$response = $client->sendRequest($yourPsr7Request); |
| 45 | +``` |
| 46 | + |
| 47 | +## 🔧 Services Registered |
| 48 | + |
| 49 | +The following services will be automatically registered in your container when using `HttpClientServiceProvider`: |
| 50 | + |
| 51 | +| Service Interface | Implementation Source | |
| 52 | +|-------------------------------------------|--------------------------------------------| |
| 53 | +| `Symfony\Component\HttpClient\HttpClient` | Registered via `MethodFactory::create()` | |
| 54 | +| `Psr\Http\Client\ClientInterface` | `Symfony\Component\HttpClient\Psr18Client` | |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## 📂 License |
| 59 | + |
| 60 | +This package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT). |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## 🤝 Contributing |
| 65 | + |
| 66 | +Contributions, issues, and feature requests are welcome! |
| 67 | +Feel free to open a [GitHub Issue](https://github.com/php-fast-forward/http-client/issues) or submit a Pull Request. |
0 commit comments