Laravel Favicon Package


February 14th, 2019

Laravel Favicon Package

Laravel Favicon is a package by Marcel Pociot that enables you to create dynamic favicons based on your environment settings:

The package works by using a favicon() helper function in your template, which is then modified in the environments you configure:

1<link rel="icon" type="image/png" sizes="32x32" href="{{ favicon(asset('favicon-32x32.png')) }}">

Here’s an example of the default enabled environment configuration at the time of writing to give you an idea the values you can specify:

1'enabled_environments' => [
2 'local' => [
3 'text' => 'DEV',
4 'color' => '#000000',
5 'background_color' => '#ffffff',
6 ],

It uses Intervention Image, which at the time of writing supports to processing extensions: gd and imagick. If you want to convert ICO files, you need to use the imagick configuration option.

The intended use of this package is for non-production environments. Environments that don’t have matching configuration values will return the original path/URI to the static icon.

Related: Laravel View X-Ray

You can learn more about the Laravel Favicon package at beyondcode/laravel-favicon. To learn how to install and use the package, check out the project’s README file.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.