Laravel Favicon Extractor

Laravel Favicon Extractor

Laravel Favicon Extractor is a package by Stefan Bauer that provides a convenient way to extract a favicon from any website and save it to the configured storage filesystem in your project.

One example use-case I could think of is grabbing the favicon to represent a website that is part of your application, for example, setting up websites to be monitored or configured as part of a database record.

Here’s how you use the library to grab the favicon:

$favicon = FaviconExtractor::fromUrl('https://laravel.com')->fetchOnly();

This method returns an object representation of the favicon, which you can then get the raw content from:

$favicon->getContent();

You can save the favicon to storage with the following:

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

The second argument is a custom filename. If you don’t provide a second argument, the library generates a filename. Either way, the call to fetchAndSaveTo() returns the storage path of the newly created file.

You can learn more about this package and check out the source code on GitHub at stefanbauer/laravel-favicon-extractor.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Remote PHP / Laravel Developer
Remote
SpringboardVR
Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
Senior Laravel Developer
Leidseplein, Amsterdam
Orderchamp.com
PHP Developer
Remote
X-Team
Senior Laravel Developer (Canada and India)
London, Ontario, Canada
Factory Bucket Inc.
Laravel, PHP, PostgreSQL, Neo4J Developer
Pune, India (intern in Denver, CO)
Life AI
Senior Laravel Developer - Cloud based SaaS product (New Zealand based)
Auckland city
Figured Limited