Skip to content

php-fast-forward/http-client

Repository files navigation

🚀 FastForward HTTP Client

PHP Version License CI

A PSR-11 compatible service provider that registers a fully functional set of PSR-18 HTTP client using Symfony HttpClient and Psr18Client.

Designed to work out of the box with the php-fast-forward/container autowiring system.


📦 Installation

composer require fast-forward/http-client

✅ Features

  • Registers the default Symfony HttpClient using `HttpClient::create()
  • Registers the PSR-18 Psr18Client with its dependencies injected
  • Provides aliases for:
    • Psr\Http\Client\ClientInterface
    • Symfony\Component\HttpClient\HttpClient

🛠️ Usage

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
        FastForward\Http\Client\ServiceProvider\HttpClientServiceProvider::class,
    ],
]);

$container = container($config);

$client = $container->get(Psr\Http\Client\ClientInterface::class);
$response = $client->sendRequest($yourPsr7Request);

🔧 Services Registered

The following services will be automatically registered in your container when using HttpClientServiceProvider:

Service Interface Implementation Source
Symfony\Component\HttpClient\HttpClient Registered via MethodFactory::create()
Psr\Http\Client\ClientInterface Symfony\Component\HttpClient\Psr18Client

📂 License

This package is open-source software licensed under the MIT License.


🤝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to open a GitHub Issue or submit a Pull Request.