Create dynamic favicons based on your environment settings.
Create dynamic favicons based on your environment settings.
Create dynamic favicons based on your environment settings.
If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.
You can install the package via composer:
composer require beyondcode/laravel-faviconThe service provider for this package will be automatically registered for you.
| 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 1.6 | 1.7 | 1.8 | |
|---|---|---|---|---|---|---|---|---|---|
| 5.6.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 5.7.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 5.8.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 6.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 7.x | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 8.x | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| 9.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
| 10.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
| 11.x | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| 12.x | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
| 13.x | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
To make use of this package, make use of the favicon helper function that this package provides.
You can simply wrap the function around your favicon icon names, like this:
You can completely customize which environments you want to have enabled for the favicon generation, as well as the font and colors that will be used.
To modify the default values, publish the package configuration file using:
php artisan vendor:publish --provider='BeyondCode\LaravelFavicon\FaviconServiceProvider' --tag='config'This will publish the config/favicon.php file.
This is what the default content looks like:
…Modify the settings to suit your needs.
The default favicon generator will write the text on the bottom-right corner of your favicon, in the desired color, font and background-color. If you want to generate a completely custom favicon, you can create your own FaviconGenerator implementation class and set it in the configuration file.
This is the interface that the generator should implement:
interface FaviconGenerator
{
public function generate(string $icon): Response;
public function shouldGenerateFavicon(): bool;
}The generate method receives the icon url/filename and expects you to return an illuminate HTTP response.
The shouldGenerateFavicon method can be used to determine if a custom favicon should get generated.
In order to modify ICO files, you need the Imagick PHP library installed and enabled in your config/favicon.php file.
No - the default generator only modifies your favicon when the specified environment is enabled. This means, that production environments only see the static assets that you already have.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
No open issues yet, or sync has not completed.