balpom/guzzle-downloader

Downloads the contents of the specified URI (or file).

v1.1.1 2024-05-28 15:43 UTC

This package is auto-updated.

Last update: 2024-10-28 16:28:09 UTC


README

Simple realisation of Balpom\UniversalDownloader\PSR18DownloadInterface based on Guzzle PHP HTTP client.

This downloader is a simple realisation of PSR18DownloadInterface from balpom/universal-downloader, based on Guzzle PHP HTTP client (guzzle/guzzle; see more information on https://guzzlephp.org).

Requirements

  • PHP >= 8.1

Installation

Using composer (recommended)

composer require balpom/guzzle-downloader

Guzzle downloader usage sample

$downloader = new \Balpom\GuzzleDownloader\Downloader();
$downloader = $downloader->get('https://ipmy.ru/ip');
$result = $downloader->result();
echo $result ->code() . PHP_EOL; // Must be 200.
echo $result ->content() . PHP_EOL; // Must be your IP.
echo $result ->mime() . PHP_EOL; // Must be "text/html".

Method "response()" return PSR7 Response (Psr\Http\Message\RequestInterface: https://www.php-fig.org/psr/psr-7/).

print_r($result->response());

Opportunities for extension

Protected method "downloader()" return Balpom\UniversalDownloader\Downloader, which created into constructor of Downloader.php. And protected method client() return GuzzleHttp\Client (which also created into constructor of Downloader.php).

License

MIT License See LICENSE.MD