PHPackages                             log1x/sage-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. log1x/sage-svg

ActivePackage[Utility &amp; Helpers](/categories/utility)

log1x/sage-svg
==============

A simple package for using inline SVGs in Sage 10 projects.

v2.0.2(1y ago)121546.7k—6.4%13[3 issues](https://github.com/Log1x/sage-svg/issues)2MITPHPPHP ^8.1

Since Jul 9Pushed 1y ago4 watchersCompare

[ Source](https://github.com/Log1x/sage-svg)[ Packagist](https://packagist.org/packages/log1x/sage-svg)[ GitHub Sponsors](https://github.com/Log1x)[ RSS](/packages/log1x-sage-svg/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (2)

Sage SVG
========

[](#sage-svg)

[![Latest Stable Version](https://camo.githubusercontent.com/31fa1aa111ebda05618908e470522a620bc6e3b4191a28c687d39ee2584bd073/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6731782f736167652d7376672e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/31fa1aa111ebda05618908e470522a620bc6e3b4191a28c687d39ee2584bd073/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6731782f736167652d7376672e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/ec39c303dccd7046e67f0eae3b2e0477f571a7be1d6f4bd809d1509301553424/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6731782f736167652d7376672e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ec39c303dccd7046e67f0eae3b2e0477f571a7be1d6f4bd809d1509301553424/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6731782f736167652d7376672e7376673f7374796c653d666c61742d737175617265)[![Build Status](https://camo.githubusercontent.com/52adbb62997e485d85b3043e6484ac2a3c3c4f59248886bc1eee5be0e39dd5bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6f6731782f736167652d7376672f6d61696e2e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/52adbb62997e485d85b3043e6484ac2a3c3c4f59248886bc1eee5be0e39dd5bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6f6731782f736167652d7376672f6d61696e2e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)

Sage SVG is a simple package for using inline SVGs in your Sage 10 projects.

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

[](#requirements)

- [Sage](https://github.com/roots/sage) &gt;= 10.x
- [Acorn](https://github.com/roots/acorn) &gt;= 4.x
- [PHP](https://secure.php.net/manual/en/install.php) &gt;= 8.1
- [Composer](https://getcomposer.org/download/)

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

[](#installation)

Install via Composer:

```
$ composer require log1x/sage-svg
```

Usage
-----

[](#usage)

By default, the following paths are checked for your SVG (in order):

- If passed an array containing `id`, it is assumed to be a WordPress attachment and is ran through [`get_attached_file()`](https://developer.wordpress.org/reference/functions/get_attached_file).
- Your default asset manifest (usually `mix-manifest.json`).
- Path relative to `config('svg.path')` which is `public_path()` by default.
- Absolute web root path.

### Blade Directive

[](#blade-directive)

Unless you require advance functionality from somewhere such as a Controller, the best way to use Sage SVG is with the Blade directive straight in your templates.

```
# Relative path (with dot notation) – resolves to `app/themes//dist/images/logo.svg` by default
@svg('images.logo')

# Absolute path from webroot with `w-32 h-auto` CSS classes and an aria-label
@svg('app/uploads/2019/07/logo.svg', 'w-32 h-auto', ['aria-label' => 'Logo'])
```

### Helper

[](#helper)

The easiest way to use SVG outside of a Blade template is the global `get_svg()` helper function. `get_svg()` will return `false` if no image is found.

```
# Relative path
$image = get_svg('images.logo');

# Absolute path from webroot with `w-32 h-auto` CSS classes
$image = get_svg('app/uploads/2019/07/logo.svg', 'w-32 h-auto');

# WordPress attachment (e.g. ACF field) with `my-logo` CSS class
$image = get_svg(
    get_field('logo_svg'),
    'my-logo'
);
```

### Facade

[](#facade)

Another option for rendering an SVG is using the `SageSvg` Facade:

```
use Log1x\SageSvg\Facades\SageSvg;

$image = SageSvg::render('images.logo');
```

Configuration
-------------

[](#configuration)

The configuration file, `svg.php`, can be published using Acorn:

```
$ wp acorn vendor:publish --provider='Log1x\SageSvg\SageSvgServiceProvider'
```

You can read the DocBlocks in `config/svg.php` for more details.

Why another SVG Package?
------------------------

[](#why-another-svg-package)

> Didn't you author Blade SVG Sage? Why another SVG package?

While I do have my fork of [Blade SVG](https://github.com/adamwathan/blade-svg) called [Blade SVG Sage](https://github.com/log1x/blade-svg-sage), I find it rather underwhelming due to the following reasons:

- Unable to handle WordPress attachments
- Unable to inline SVGs that aren't set in a specific path
- Unable to properly use the asset manifest.
- I know QWp6t

Bug Reports
-----------

[](#bug-reports)

If you discover a bug in Sage SVG, please [open an issue](https://github.com/log1x/sage-svg/issues).

Contributing
------------

[](#contributing)

Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.

License
-------

[](#license)

Sage SVG is provided under the [MIT License](https://github.com/log1x/sage-svg/blob/master/LICENSE.md).

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 70.1% 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 ~156 days

Recently: every ~99 days

Total

13

Last Release

627d ago

Major Versions

v1.1.2 → v2.0.02024-07-16

PHP version history (5 changes)v1.0.0PHP &gt;=7.1.3

v1.0.3PHP &gt;=7.2

v1.0.5PHP &gt;=7.2.5

v1.1.0PHP ^7.4|^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5745907?v=4)[Brandon](/maintainers/Log1x)[@Log1x](https://github.com/Log1x)

---

Top Contributors

[![Log1x](https://avatars.githubusercontent.com/u/5745907?v=4)](https://github.com/Log1x "Log1x (47 commits)")[![ouun](https://avatars.githubusercontent.com/u/32090713?v=4)](https://github.com/ouun "ouun (4 commits)")[![kellymears](https://avatars.githubusercontent.com/u/397606?v=4)](https://github.com/kellymears "kellymears (4 commits)")[![knowler](https://avatars.githubusercontent.com/u/6908001?v=4)](https://github.com/knowler "knowler (3 commits)")[![LeoColomb](https://avatars.githubusercontent.com/u/846943?v=4)](https://github.com/LeoColomb "LeoColomb (2 commits)")[![QWp6t](https://avatars.githubusercontent.com/u/2104321?v=4)](https://github.com/QWp6t "QWp6t (1 commits)")[![bekahmcdonald](https://avatars.githubusercontent.com/u/16743407?v=4)](https://github.com/bekahmcdonald "bekahmcdonald (1 commits)")[![SergiArias](https://avatars.githubusercontent.com/u/13618783?v=4)](https://github.com/SergiArias "SergiArias (1 commits)")[![catgofire](https://avatars.githubusercontent.com/u/4309?v=4)](https://github.com/catgofire "catgofire (1 commits)")[![cleverington](https://avatars.githubusercontent.com/u/1015474?v=4)](https://github.com/cleverington "cleverington (1 commits)")[![oxyc](https://avatars.githubusercontent.com/u/302736?v=4)](https://github.com/oxyc "oxyc (1 commits)")[![palicko](https://avatars.githubusercontent.com/u/4531209?v=4)](https://github.com/palicko "palicko (1 commits)")

---

Tags

blade-directivessagesvgwordpresswordpresssvgsage

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/log1x-sage-svg/health.svg)

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

###  Alternatives

[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[log1x/pagi

A better WordPress pagination.

59105.4k](/packages/log1x-pagi)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[log1x/crumb

A simple WordPress breadcrumb for Sage 10.

4373.7k](/packages/log1x-crumb)[log1x/blade-svg-sage

Composer package to add support for Blade SVG by Adam Wathan to Roots Sage.

7577.3k](/packages/log1x-blade-svg-sage)[smithfield-studio/acf-svg-icon-picker

Add ACF field for selecting SVG icons.

3710.8k](/packages/smithfield-studio-acf-svg-icon-picker)

PHPackages © 2026

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