oneup/favicon-fetcher

List and download favicons from urls

1.0.0 2024-02-23 15:14 UTC

This package is auto-updated.

Last update: 2024-10-23 17:00:12 UTC


README

use Oneup\FaviconFetcher\FaviconFetcher;
use Oneup\FaviconFetcher\SizeParser;
use Oneup\FaviconFetcher\Strategy\RelIconStrategy;
use Oneup\FaviconFetcher\Strategy\AppleTouchIconStrategy;
use Oneup\FaviconFetcher\UrlNormalizer;

$httpClient = ...

$sizeParser = new SizeParser();
$urlNormalizer = new UrlNormalizer();

$faviconFetcher = new FaviconFetcher($httpClient, [
    new RelIconStrategy($sizeParser, $urlNormalizer),
    new AppleTouchIconStrategy($sizeParser, $urlNormalizer),
]);

$collection = $faviconFetcher->fetch('https://1up.io');
$favicon = $collection->findOneByMinimumSize(32, 32);

$contents = $faviconFetcher->download($favicon);