bulaws / url-image-downloader
Image download by url
dev-master
2020-10-26 20:13 UTC
Requires
- php: ^7.4.5
- guzzlehttp/guzzle: ^6.5
Requires (Dev)
- phpunit/phpunit: ^9.4
This package is not auto-updated.
Last update: 2025-04-22 16:37:21 UTC
README
This library uses Guzzle PHP.
Installation
The best way to install using composer. Run command in your project:
composer require "bulaws/url-image-downloader": "dev-master"
Or add to require section composer.json:
"bulaws/url-image-downloader": "dev-master"
And run composer update.
Get starting
Create validate object or you can create your own class validate implement FileValidator class:
$imageValidator = new ImageValidator();
Create componet object and insert to ImageDownload:
$downloader = new Image\Downloader\ImageDownload($imageValidator);
For download you call method of ImageDownload class:
$downloader->imageDownloadByUrl($url, $pathSave, $fileName);
In accordance to method get image by url and will be save to your path with name.
Example
$imageValidator = new ImageValidator();
$downloader = new Image\Downloader\ImageDownload($imageValidator);
$downloader->imageDownloadByUrl('https://24tv.ua/resources/photos/news/1200x675_DIR/201908/1195520.jpg?201908174431', 'image', 'field.jpg');