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)03.7k↓26.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 1mo 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 64% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

543d 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

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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