Download the PHP package hieu-le/favicon without Composer
On this page you can find all versions of the php package hieu-le/favicon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package favicon
favicon
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.json
file 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
meta
andlink
tags 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.
Run composer update
and start using.
Generate images
To use the command line to to generate favicon files:
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-48
and--ico-64
options make the output icon file larger a lot.--no-old-apple
: exclude pngs files that used by old Apple touch devices--no-android
: excludemanifest.json
files and PNG files for Android devices--no-ms
: exclude images for Windows tile--app-name="..."
set the application name in themanifest.json
file. Default is an empty string.
Output HTML tags
Call the favicon
function inside your HTML template as follow:
The $option
argument is a bitmask with following bit:
FAVICON_NO_OLD_APPLE
: do not include old apple touchlink
tagsFAVICON_NO_ANDROID
: do not include Androidmanifest.xml
link tagFAVICON_NO_MS
: do not include Windows and IEmeta
tags
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
link
tags:FAVICON_NO_OLD_APPLE
- To exclude Android manifest file and IE
meta
tags: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.xml
fileapplication_name
: the default application name displayed when user pinned this site
The result of
is a HTML segment link this:
License
The package is released under MIT license. See the LICENSE
file for more detail.