hieu-le/favicon
Composer 安装命令:
composer require hieu-le/favicon
包简介
A configurable PHP solution to auto generate favicons and HTML meta tags from a original PNG file.
README 文档
README
A configurable PHP solution to auto generate favicons and HTML tags from a original PNG file.
What does this package do?
In short, it will help you display correct favicon for your website with just one original PNG image.
In more details, it supports:
- create one ICO file and many PNG files with many favicon sizes from just one original PNG image as well as a
manifest.jsonfile for Android devices. Both input file path and output folder (which contains images and json files) are configurable via a command line interface. - Generate suitable
metaandlinktags for desktop web browsers as well as mobile touch devices to properly display favicon.
Installation
We need PHP imagick extension or PHP GD extension for generating images. By default, the Imagick extension is loaded, if you cannot install it, you can switch to using GD via command line option if available.
You will need (Composer)[] to use this package. After install Composer, add this dependency into your composer.json file.
"hieu-le/favicon" : "~1.0"
Run composer update and start using.
Generate images
To use the command line to to generate favicon files:
$ vendor/bin/favicon generate [--ico-64] [--ico-48] [--no-old-apple] [--no-android] [--no-ms] [--app-name="..."] input [output]
Arguments:
input: path to the input image files, which is requiredoutput: path to the folder which contains output files. If this folder does not exist, the package will try to create it. This argument is optional, default value is current folder.
Options:
The Imagick ext is used by default. GD library is used if cannot load Imagick ext.--use-gd: use GD extension instead of Imagick extension--ico-64: include the 64x64 image inside the output ICO file (which contains only 16x16 and 32x32 images by default)--ico-48: include the 48x48 image inside the output ICO file (which contains only 16x16 and 32x32 images by default). Both--ico-48and--ico-64options make the output icon file larger a lot.--no-old-apple: exclude pngs files that used by old Apple touch devices--no-android: excludemanifest.jsonfiles and PNG files for Android devices--no-ms: exclude images for Windows tile--app-name="..."set the application name in themanifest.jsonfile. Default is an empty string.
Output HTML tags
Call the favicon function inside your HTML template as follow:
echo favicon($option = FAVICON_ENABLE_ALL, array $msOptions = array())
The $option argument is a bitmask with following bit:
FAVICON_NO_OLD_APPLE: do not include old apple touchlinktagsFAVICON_NO_ANDROID: do not include Androidmanifest.xmllink tagFAVICON_NO_MS: do not include Windows and IEmetatags
The default value is FAVICON_ENABLE_ALL turns of all these three bit and include everything in the final output. Here are some examples:
- To exclude old apple touch
linktags:FAVICON_NO_OLD_APPLE - To exclude Android manifest file and IE
metatags:FAVICON_NO_ANDROID | FAVICON_NO_MS - To exclude all these additional tags:
FAVICON_NO_OLD_APPLE | FAVICON_NO_ANDROID | FAVICON_NO_MS
The $msOptions argument is an array contains information for Windows and IE. It can has these fields:
tile_color: the background of live tile when this site is pinned, default is white (#ffffff)browser_config_file: the path to browser config XML file if you have it. By default, it is set to an empty string to prevent IE from auto lookingbrowserconfig.xmlfileapplication_name: the default application name displayed when user pinned this site
The result of
echo favicon(FAVICON_ENABLE_ALL, array( 'tile_color' => '#F0F0F0', 'browser_config_file' => 'IEConfig.xml', 'application_name' => 'Hieu Le Favicon' ));
is a HTML segment link this:
<meta name="msapplication-config" content="/IEConfig.xml" /> <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png" /> <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png" /> <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png" /> <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png" /> <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png" /> <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png" /> <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png" /> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png" /> <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32" /> <link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192" /> <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16" /> <link rel="manifest" href="/manifest.json" /> <meta name="application-name" content="Hieu Le Favicon" /> <meta name="msapplication-TileColor" content="#F0F0F0" /> <meta name="msapplication-TileImage" content="/mstile-144x144.png" /> <meta name="msapplication-square70x70logo" content="/mstile-70x70.png" /> <meta name="msapplication-square150x150logo" content="/mstile-150x150.png" /> <meta name="msapplication-wide310x150logo" content="/mstile-310x150.png" /> <meta name="msapplication-square310x310logo" content="/mstile-310x310.png" />
License
The package is released under MIT license. See the LICENSE file for more detail.
hieu-le/favicon 适用场景与选型建议
hieu-le/favicon 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 498 次下载、GitHub Stars 达 12, 最近一次更新时间为 2015 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「png」 「generate」 「favicon」 「ico」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hieu-le/favicon 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hieu-le/favicon 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hieu-le/favicon 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Library to get the apple-touch-icons and favicon from a website.
A favicon extractor for Laravel
Powertools for much lazy with Laminas because I hate writing Controllers, Forms, InputFilters, their Factories, and you hate writing all that stuff too.
Adding favicons to your site the simple way.
Generate realfavicon from your Statamic control panel
Simplistic templating for adding favicons for multiple devices
统计信息
- 总下载量: 498
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-17