PHPackages                             alto/favicon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. alto/favicon

ActiveLibrary[CLI &amp; Console](/categories/cli)

alto/favicon
============

Generate a modern favicon set (SVG icon, apple-touch-icon, favicon.ico, Web Manifest) from a single SVG or PNG file.

v1.0.0(4mo ago)43MITPHPPHP &gt;=8.3CI passing

Since Dec 24Pushed 4mo agoCompare

[ Source](https://github.com/PhpAlto/favicon)[ Packagist](https://packagist.org/packages/alto/favicon)[ Docs](https://github.com/phpalto/favicon)[ GitHub Sponsors](https://github.com/sponsors/smnandre)[ RSS](/packages/alto-favicon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Alto Favicon
============

[](#alto-favicon)

A modern, efficient PHP library and CLI tool to generate a complete favicon set from a single SVG or PNG source.

It follows the [modern best practices (2025)](https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs) to generate a minimal yet robust set of icons for all browsers and devices.

Features
--------

[](#features)

- **Minimal Output**: Generates only the necessary files to cover all modern use cases.
- **SVG Support**: Preserves your vector logo for modern browsers (`icon.svg`).
- **Legacy Support**: Generates a 32x32 `favicon.ico` for older browsers.
- **Mobile Ready**: Generates `apple-touch-icon.png` and Android icons (`icon-192.png`, `icon-512.png`).
- **PWA Ready**: Automatically generates a `manifest.webmanifest`.
- **Search Friendly**: Optionally generates a 48x48 PNG for Google Search results.
- **HTML Snippet**: Outputs the exact HTML tags you need to include in your ``.
- **Flexible Rasterization**: Supports multiple adapters for image processing:
    - SVG: `rsvg-convert`, `inkscape`, or `imagemagick` (CLI)
    - PNG: `ext-imagick` or `ext-gd`

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- For PNG processing: `ext-imagick` (recommended) OR `ext-gd`
- For SVG input, one of the following must be installed on your system:
    - `rsvg-convert` (part of `librsvg`, recommended)
    - `inkscape`
    - `imagemagick` (`magick` or `convert`)

Installation
------------

[](#installation)

```
composer require alto/favicon
```

Usage
-----

[](#usage)

### CLI

[](#cli)

Run the tool using the binary:

```
vendor/bin/favicon path/to/logo.svg
```

### Programmatic Usage

[](#programmatic-usage)

You can use the `FaviconGenerator` class directly in your PHP application (e.g., in a CMS, build script, or controller).

```
use Alto\Favicon\Generator\FaviconGenerator;
use Alto\Favicon\Options\FaviconOptionsBuilder;

// 1. Configure options
$options = (new FaviconOptionsBuilder(
    inputFile: 'assets/logo.svg',
    outputDir: 'public/favicons'
))
    ->publicPath('/favicons')
    ->appName('My App')
    ->themeColor('#0b0b0b')
    ->build();

// 2. Generate
$generator = new FaviconGenerator();
$report = $generator->generate($options);

// 3. Use the result
echo "Generated " . count($report->files) . " files.\n";
echo "HTML Snippet:\n" . $report->htmlSnippet;
```

#### `FaviconOptionsBuilder` API

[](#faviconoptionsbuilder-api)

MethodDescriptionDefault`__construct(string $inputFile, string $outputDir)`Initialize with input file and output directory.-`publicPath(string $path)`Set the public URL prefix for generated files.`/``appName(string $name)`Set the application name for the manifest.`App``themeColor(string $color)`Set the theme color (meta tag &amp; manifest).`#0b0b0b``backgroundColor(string $color)`Set the background color (manifest).`#ffffff``generateManifest(bool $generate)`Enable/disable manifest generation.`false``generateSearchPng48(bool $generate)`Enable/disable 48x48 PNG generation.`false``force(bool $force)`Enable/disable overwriting existing files.`false``build(): FaviconOptions`Build the options object.-#### `GenerationReport` Properties

[](#generationreport-properties)

The `generate()` method returns a `GenerationReport` object with the following properties:

- `outputDir` (string): The directory where files were written.
- `publicPath` (string): The public URL prefix used.
- `files` (array&lt;string, int&gt;): Map of generated filenames to their size in bytes.
- `htmlSnippet` (string): The HTML tags to include in your ``.
- `manifestFile` (?string): The name of the manifest file (if generated).
- `totalBytes()` (int): Helper method to get total size of generated files.

### Options (CLI)

[](#options-cli)

OptionDescriptionDefault`--output`, `-o`Output directory for generated files`public``--public-path`Public path prefix used in HTML/manifest`/``--app-name`Application name used in the manifest`App``--theme-color`Theme color for browser UI and manifest`#0b0b0b``--background-color`Background color for the manifest`#ffffff``--manifest`Generate `manifest.webmanifest` and Android icons`false``--search-png`Generate the 48x48 PNG favicon`false``--force`, `-f`Overwrite existing files`false`### Examples

[](#examples)

**Basic usage (Minimal set):**

```
vendor/bin/favicon assets/logo.svg
```

**Full set with Manifest and Search Icon:**

```
vendor/bin/favicon assets/logo.svg --manifest --search-png
```

**Customizing output and colors:**

```
vendor/bin/favicon assets/logo.svg \
    --output public/assets/favicons \
    --public-path /assets/favicons \
    --app-name "My Awesome App" \
    --theme-color "#3b82f6"
```

**Using a PNG source (if you don't have SVG):**

```
vendor/bin/favicon assets/logo.png
```

*Note: When using PNG input, `icon.svg` will not be generated, and 16x16/32x32 PNGs will be used as fallbacks.*

Generated Files
---------------

[](#generated-files)

The tool generates the following structure in your output directory:

- `favicon.ico` (Legacy support)
- `icon.svg` (Modern browsers)
- `apple-touch-icon.png` (iOS)
- `favicon.html` (HTML snippet to include)

**Optional files (with `--manifest` and `--search-png`):**

- `icon-192.png` (Android)
- `icon-512.png` (Android)
- `icon-maskable.png` (Android maskable icon)
- `manifest.webmanifest` (Web App Manifest)
- `favicon-48x48.png` (Google Search)

Testing
-------

[](#testing)

To run the test suite:

```
composer test
```

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance75

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8951d49b371d210280a58ce48969a07d1f49924810f8a1fab3a9343eb46fdc9?d=identicon)[simonandre](/maintainers/simonandre)

---

Top Contributors

[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (4 commits)")

---

Tags

altoapple-touch-iconcli-toolfavicongeneratoriconphp-svgphp-toolpngsvgwebmanifestphpcligeneratorsvgpngfaviconphp-cliiconicomanifestwebmanifestapple-touch-iconalto

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alto-favicon/health.svg)

```
[![Health](https://phpackages.com/badges/alto-favicon/health.svg)](https://phpackages.com/packages/alto-favicon)
```

###  Alternatives

[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[jkphl/iconizr

A PHP command line tool for converting SVG images to a set of CSS icons (SVG &amp; PNG, single icons and / or CSS sprites) with support for image optimization and Sass output

4868.9k](/packages/jkphl-iconizr)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1322.1k12](/packages/mahocommerce-maho)[timwassenburg/laravel-artisan-extender

A collection of generators for Laravel

111.4k](/packages/timwassenburg-laravel-artisan-extender)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
