PHPackages                             vestaware/svg-sprite-generator - 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. [Image &amp; Media](/categories/media)
4. /
5. vestaware/svg-sprite-generator

ActiveLibrary[Image &amp; Media](/categories/media)

vestaware/svg-sprite-generator
==============================

A PHP library to optimize SVG files and generate SVG sprites.

v1.0.4(1y ago)05.4k—2%MITPHPPHP &gt;=7.4

Since Nov 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/vestaware/svg-sprite-generator)[ Packagist](https://packagist.org/packages/vestaware/svg-sprite-generator)[ RSS](/packages/vestaware-svg-sprite-generator/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

SVG Sprite Generator
====================

[](#svg-sprite-generator)

A PHP library to optimize SVG files and generate an SVG sprite.

---

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

[](#installation)

Install the package using [Composer](https://getcomposer.org/):

```
composer require vestaware/svg-sprite-generator
```

---

Usage
-----

[](#usage)

### Example:

[](#example)

```
use Vestaware\SvgSpriteGenerator\SvgSpriteGenerator;

// Define the input directory containing SVG files
$inputDir = __DIR__ . '/svgs';

// Define the output directory for the SVG sprite
$outputDir = __DIR__ . '/output';

// Define the base file name for the sprite
$baseFileName = 'sprite';

// Define the path for the manifest file
$manifestPath = $outputDir . '/sprite-manifest.json';

// Create an instance of the generator
$generator = new SvgSpriteGenerator($inputDir, $outputDir, $baseFileName, $manifestPath, removeFill: true);

// Generate the SVG sprite
$generator->generateSprite();

// Load the manifest to retrieve the generated file name
$manifest = json_decode(file_get_contents($manifestPath), true);
$generatedFileName = $manifest[$baseFileName];

echo "SVG sprite generated at: $outputDir/$generatedFileName";
```

Features
--------

[](#features)

- Removes unnecessary attributes like `id`, `xmlns`, and others.
- Retains only `viewBox` and optionally `fill` attributes.
- Removes `` tags completely.
- Supports versioning for the generated sprite file.
- Generates a manifest file mapping the base file name to the versioned file name.
- Automatically deletes old versions of the sprite file to save space.

---

Output Example
--------------

[](#output-example)

The generated SVG sprite will look like this:

```

```

### Example Manifest

[](#example-manifest)

The manifest file contains the mapping of the base file name to the versioned file name:

```
{
  "sprite": "sprite.abc12345.min.svg"
}
```

License
-------

[](#license)

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Every ~0 days

Total

5

Last Release

590d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vestaware-svg-sprite-generator/health.svg)

```
[![Health](https://phpackages.com/badges/vestaware-svg-sprite-generator/health.svg)](https://phpackages.com/packages/vestaware-svg-sprite-generator)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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