PHP code example of oneup / favicon-fetcher

1. Go to this page and download the library: Download oneup/favicon-fetcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oneup / favicon-fetcher example snippets


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);