ovvio/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

v1.0.0 2024-12-30 04:29 UTC

This package is auto-updated.

Last update: 2025-06-29 02:10:07 UTC


README

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

Technical Requirements & Installation

PHP 8.4 - Installation and Configuration

Composer (System Requirements)

To install run this:

composer require ovvio/http-client

Example

...

use Ovvio\Component\Http\HttpClient\HttpClientInterface;
use Ovvio\Component\Http\HttpClient\Request\Enum\RequestMethod;
use Ovvio\Component\Http\HttpClient\Response\Enum\ResponseStatusCode;

...

    public function __construct(
        private readonly HttpClientInterface $httpClient,
    ) {
    }

...

    public function foo(FooDtoInterface $fooDto): void
    {

        ...

        /** @var string $url URL */
        $url = 'https://ovvio.pro';
        $requestMethod = RequestMethod::GET;

        $request = RequestFactory::create(
            url: $url,
            method: $requestMethod,
        );

        $response = $this->httpClient->request($request);
        if ($response->getStatusCode() !== ResponseStatusCode::HTTP_OK) {
            // do something
        }

        ...

    }

...