PHPackages                             ui-awesome/html-svg - 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. ui-awesome/html-svg

ActiveLibrary

ui-awesome/html-svg
===================

UI Awesome HTML SVG Library for PHP.

0.3.2(3mo ago)210.2k2BSD-3-ClausePHPPHP ^8.1CI passing

Since Mar 22Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ui-awesome/html-svg)[ Packagist](https://packagist.org/packages/ui-awesome/html-svg)[ RSS](/packages/ui-awesome-html-svg/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (14)Versions (8)Used By (2)

    ![UI Awesome](https://raw.githubusercontent.com/ui-awesome/.github/refs/heads/main/logo/ui_awesome_dark.png)

Html SVG
========

[](#html-svg)

 [ ![PHPUnit](https://camo.githubusercontent.com/e0841755d82c0dfa5cc45c759d0c65ea2691f4c6c6780121a0e8a96743820eaa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f75692d617765736f6d652f68746d6c2d7376672f6275696c642e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d504850556e6974266c6f676f3d676974687562) ](https://github.com/ui-awesome/html-svg/actions/workflows/build.yml) [ ![Mutation Testing](https://camo.githubusercontent.com/880abcf04b7a036ea434d7e7db046de8fc4fdffc50c5a536ac9f0f888d07e604/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666f722d7468652d62616467652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324675692d617765736f6d6525324668746d6c2d7376672532466d61696e) ](https://dashboard.stryker-mutator.io/reports/github.com/ui-awesome/html-svg/main) [ ![PHPStan](https://camo.githubusercontent.com/944bfbafae2aee260dd17494fe611fae255f163e09d44a21074ddba3ce502075/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f75692d617765736f6d652f68746d6c2d7376672f7374617469632e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d5048505374616e266c6f676f3d676974687562) ](https://github.com/ui-awesome/html-svg/actions/workflows/static.yml)

 **A robust, fluent, and immutable PHP library for generating and manipulating SVG elements.**
 *Secure file loading, accessibility-first design, and standards-compliant rendering.*

Features
--------

[](#features)

  ![Feature Overview](./docs/svgs/features-mobile.svg)### Installation

[](#installation)

```
composer require ui-awesome/html-svg:^0.3
```

### Quick start

[](#quick-start)

This library provides an immutable, fluent API for generating SVG markup in PHP.

It supports composing SVG elements using wrapper classes, secure SVG loading from the filesystem, and accessibility-first rendering.

#### Gradients + composition + immutability

[](#gradients--composition--immutability)

```
use UIAwesome\Html\Svg\{Circle, Defs, LinearGradient, Stop, Svg};

$defs = Defs::tag()
    ->html(
        LinearGradient::tag()
            ->html(
                Stop::tag()->offset('0%')->stopColor('#16a34a')->stopOpacity(1),
                Stop::tag()->offset('100%')->stopColor('#22c55e')->stopOpacity(1),
            )
            ->id('accent')
            ->x1('0%')
            ->x2('100%')
            ->y1('0%')
            ->y2('0%')
    );

$baseCircle = Circle::tag()->cx(60)->cy(60)->r(46)->stroke('#064e3b')->strokeWidth(3);

echo Svg::tag()
    ->html(
        $defs,
        $baseCircle->fill('none')->opacity(0.25)->transform('translate(6 6)'),
        $baseCircle->fill('url(#accent)'),
    )
    ->height(120)
    ->title('Gradient badge example')
    ->viewBox('0 0 120 120')
    ->width(120)
    ->render();
```

#### Yii icon (inline)

[](#yii-icon-inline)

```
use UIAwesome\Html\Svg\{Path, Svg};

$yiiPath = viewBox('0 0 24 24')
    ->title('Yii')
    ->html(Path::tag()->d($yiiPath)->fill('currentColor'))
    ->render();
```

#### Loading from file (secure)

[](#loading-from-file-secure)

```
use UIAwesome\Html\Svg\Svg;

// Loads, sanitizes, and injects an external SVG file.
echo Svg::tag()
    ->class('icon-lg')
    ->filePath('/path/to/icon.svg')
    ->fill('currentColor')
    ->title('Icon')
    ->render();
```

Note: If both the internal `content` and `filePath()` are empty, an exception is thrown.

Documentation
-------------

[](#documentation)

For detailed configuration options and advanced usage.

- 🧪 [Testing Guide](docs/testing.md)
- 🛠️ [Development Guide](docs/development.md)

Package information
-------------------

[](#package-information)

[![PHP](https://camo.githubusercontent.com/8c0cc099469e78d1c3ab294bd8b4e29dd7ad459d84ca953058f4034eeb3e0695/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f253345253344382e312d3737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/releases/8.1/en.php)[![Latest Stable Version](https://camo.githubusercontent.com/86be9fc979fbacd2f4694a609687bdce69984904ef2de9e9c4ba4da52c2e3f26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75692d617765736f6d652f68746d6c2d7376672e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465266c6162656c3d537461626c65)](https://packagist.org/packages/ui-awesome/html-svg)[![Total Downloads](https://camo.githubusercontent.com/33a29e59eac3b40f547e0e3390a4f224c4954910befb4168d1ed4860072ea638/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75692d617765736f6d652f68746d6c2d7376672e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465266c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/ui-awesome/html-svg)

Quality code
------------

[](#quality-code)

[![Codecov](https://camo.githubusercontent.com/a5019e956f498dcee3990a47c656b84dd149401ae4dd170bbae6e8cd2097eaa4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f75692d617765736f6d652f68746d6c2d7376672e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6465636f76266c6f676f436f6c6f723d7768697465266c6162656c3d436f766572616765)](https://codecov.io/github/ui-awesome/html-svg)[![PHPStan Level Max](https://camo.githubusercontent.com/b1aeb44257ce46737d1787123b534aab9dded28219f828e4ae13a1e3b460f53c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d3446354439352e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.com/ui-awesome/html-svg/actions/workflows/static.yml)[![Super-Linter](https://camo.githubusercontent.com/8709b1a302548efb7dbbf51178fc7ee25237fd3bb5c4d93a02e127eccd3a5284/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f75692d617765736f6d652f68746d6c2d7376672f6c696e7465722e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d53757065722d4c696e746572266c6f676f3d676974687562)](https://github.com/ui-awesome/html-svg/actions/workflows/linter.yml)[![StyleCI](https://camo.githubusercontent.com/2e44ba381d6c9ab95b548566772bd17337dc56f8a6a646974bf7277720e5be9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374796c6543492d5061737365642d3434434331312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.styleci.io/repos/776094320?branch=main)

Our social networks
-------------------

[](#our-social-networks)

[![Follow on X](https://camo.githubusercontent.com/332c1b1e043dfb940b95825f7863dc473f6924ddacdd6738cbbbba08f49e1862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d466f6c6c6f772532306f6e253230582d3144413146322e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d78266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://x.com/Terabytesoftw)

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/680c8d62ba2d5a71d7099b6e81114fb0b22d99086c121fd178e1149afc669d44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4253442d2d332d2d436c617573652d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e736f75726365696e6974696174697665266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](LICENSE)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance79

Regular maintenance activity

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

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 ~169 days

Total

5

Last Release

111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/524d2b46690f41fce7188d369488a35e7624e6c5a264d82aacd08548bfd156ab?d=identicon)[terabytesoftw](/maintainers/terabytesoftw)

---

Top Contributors

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

---

Tags

phplibraryhtmlsvgui-awesome

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ui-awesome-html-svg/health.svg)

```
[![Health](https://phpackages.com/badges/ui-awesome-html-svg/health.svg)](https://phpackages.com/packages/ui-awesome-html-svg)
```

###  Alternatives

[picqer/php-barcode-generator

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.8k25.5M88](/packages/picqer-php-barcode-generator)

PHPackages © 2026

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