Skip to content
Extract a favicon from any website and save it to your local storage
Branch: master
Clone or download
Latest commit 62c566e May 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
config add missing comma in config array Aug 21, 2018
src remove url validation as it's not necessary Oct 6, 2018
tests remove apropriate tests Oct 6, 2018
.gitignore initial commit Aug 20, 2018
.php_cs.dist initial commit Aug 20, 2018
.travis.yml initial commit Aug 20, 2018 update changelog Aug 21, 2018 initial commit Aug 20, 2018 initial commit Aug 20, 2018 initial commit Aug 20, 2018
composer.json Support Laravel 5.8 May 4, 2019
phpunit.xml.dist initial commit Aug 20, 2018

Laravel Favicon Extractor

Latest Version on Packagist Build Status Total Downloads Software License

This package provides a convenient way to extract a favicon from any website by using the appropriate Google service. It allows you to fetch and save it to your local storage.


Usage is very simple. You can either pull it in via Dependency Injection or use the Facade.

  • For the Dependency Injection version, type hint the FaviconExtractorInterface.
  • For the Facade version, use the FaviconExtractor Facade.


  • If no favicon could be found, it returns a default one.
  • The favicon's extension is always .png. It's not necessary to be part of your filename.

Fetch the favicon only

$favicon = FaviconExtractor::fromUrl('')->fetchOnly();

It returns a instance which implements FaviconInterface where you can retrieve the raw content of the favicon with $favicon->getContent().

Fetch and download the favicon

If you prefer to save the favicon to your local storage, you can. The only requirement is to define the path, where the favicon should be saved. It's relative to your root path which you defined in config/filesystems.php. Saying your path to save is favicons, it will be saved to app/storage/favicons.

With a random generated filename

// returns favicons/HIgLtwL0iUdNkwfq.png

With a custom filename

FaviconExtractor::fromUrl('')->fetchAndSaveTo('favicons', 'myFilename');
// returns favicons/myFilename.png


To install this package, require it via composer.

$ composer require stefanbauer/laravel-favicon-extractor

Thanks to Laravel 5.5+ Package Auto-Discovery, there is no need to add the ServiceProvider manually. If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php.


If you want to use the facade, add this to your facades array in config/app.php.

'FaviconExtractor' => StefanBauer\LaravelFaviconExtractor\Facades\FaviconExtractor::class,


If you would like to modify the configuration, use the publish command to copy the package config over.

php artisan vendor:publish --provider="StefanBauer\LaravelFaviconExtractor\FaviconExtractorServiceProvider" --tag="config"

The configuration file has only two options you can change. The provider_class and the filename_generator_class. In general, there is no need to change it, unless you like to have a different implementations how the favicon is fetched and how the filename is generated. Pleae take care of implementing the corresponding interfaces.


$ vendor/bin/phpunit


Please take a look at the CHANGELOG what has changed recently.


Please take a look at CONTRIBUTING for more information.


The MIT License (MIT). Please take a look at the LICENSE for more information.

You can’t perform that action at this time.