balpom / guzzle-downloader
Downloads the contents of the specified URI (or file).
v1.1.1
2024-05-28 15:43 UTC
Requires
- php: >=8.1
- balpom/universal-downloader: ^1.4
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.6
- psr/http-message: ^2.0
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