开源软件名称(OpenSource Name):beyondcode/laravel-favicon开源软件地址(OpenSource Url):https://github.com/beyondcode/laravel-favicon开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Laravel FaviconCreate dynamic favicons based on your environment settings. Laravel Package DevelopmentIf you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course. InstallationYou can install the package via composer: composer require beyondcode/laravel-favicon The service provider for this package will be automatically registered for you. UsageTo make use of this package, make use of the You can simply wrap the function around your favicon icon names, like this: <link rel="icon" type="image/png" sizes="32x32" href="{{ favicon(asset('favicon-32x32.png')) }}">
<link rel="shortcut icon" href="{{ favicon('favicon.ico') }}" /> CustomizationYou 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:
This will publish the This is what the default content looks like: return [
/*
* The list of enabled environments for the dynamic favicon
* generation. You can specify the text to display as well
* as the font and background color for the text.
*
* If no background color is specified, the text will be
* on a transparent background.
*/
'enabled_environments' => [
'local' => [
'text' => 'DEV',
'color' => '#000000',
'background_color' => '#ffffff',
],
],
/*
* The dynamic favicon text padding to apply.
*/
'padding' => [
'x' => 2,
'y' => 2,
],
/*
* The font file to use for the dynamic favicon generation.
* The default value will use OpenSans Regular.
*/
'font' => null,
/*
* Intervention Image supports "GD Library" and "Imagick" to process images
* internally. You may choose one of them according to your PHP
* configuration. By default PHP's "GD Library" implementation is used.
*
* If you want to convert ICO files, you need to use imagick.
*
* Supported: "gd", "imagick"
*
*/
'image_driver' => 'gd',
/*
* The prefix to use for the dynamic favicon URL.
*/
'url_prefix' => 'laravel-favicon',
/*
* The favicon generator class to use. The default generator
* makes use of the environment settings defined in this file.
* But you can create your own favicon generator if you want.
*/
'generator' => \BeyondCode\LaravelFavicon\Generators\EnvironmentGenerator::class,
]; Modify the settings to suit your needs. Custom generatorThe 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 The FAQ
In order to modify ICO files, you need the Imagick PHP library installed and enabled in your
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. ChangelogPlease see CHANGELOG for more information what has changed recently. ContributingPlease see CONTRIBUTING for details. SecurityIf you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker. CreditsLicenseThe MIT License (MIT). Please see License File for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论