PHPackages                             digifactory/laravel-svg-fixer-middleware - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. digifactory/laravel-svg-fixer-middleware

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

digifactory/laravel-svg-fixer-middleware
========================================

Fixes your uploaded SVG files before validating through the Laravel validator

v5.0.1(2mo ago)534.7k↓48.3%MITPHPPHP ^8.3CI failing

Since Oct 29Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/digifactory/laravel-svg-fixer-middleware)[ Packagist](https://packagist.org/packages/digifactory/laravel-svg-fixer-middleware)[ Docs](https://github.com/digifactory/laravel-svg-fixer-middleware)[ RSS](/packages/digifactory-laravel-svg-fixer-middleware/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (10)Versions (21)Used By (0)

Fix 'invalid' SVG files
=======================

[](#fix-invalid-svg-files)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e915b4fc740de64c9138e267a0b22b1696fa4aee866109e4ad829c75f7341e7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696769666163746f72792f6c61726176656c2d7376672d66697865722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digifactory/laravel-svg-fixer-middleware)[![MIT Licensed](https://camo.githubusercontent.com/45391b59b4eb46dec44118d0aa41417ea58e008359aedffbcd40ab0f28db7440/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64696769666163746f72792f6c61726176656c2d7376672d66697865722d6d6964646c65776172653f7374796c653d666c61742d737175617265)](LICENSE.md)[![run-tests](https://github.com/digifactory/laravel-svg-fixer-middleware/actions/workflows/run-php-tests.yml/badge.svg)](https://github.com/digifactory/laravel-svg-fixer-middleware/actions/workflows/run-php-tests.yml)[![Quality Score](https://camo.githubusercontent.com/5f54307f9d1f3ee9fd2f2aec75bee1276fa64d805771fe789fa29376e424fc06/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f64696769666163746f72792f6c61726176656c2d7376672d66697865722d6d6964646c65776172652f6d61737465723f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/digifactory/laravel-svg-fixer-middleware)[![StyleCI](https://camo.githubusercontent.com/0d18c0fe6daf5428b7a2aedcb7551135bc2c22dc52d387828b83524cb1a07ef5/68747470733a2f2f7374796c6563692e696f2f7265706f732f3231373639303634352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/217690645)[![Total Downloads](https://camo.githubusercontent.com/7a1b7ca9d44ba5cd77a2062903f49abc23dbae798648d2d508ceff25ccb0f0c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696769666163746f72792f6c61726176656c2d7376672d66697865722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/digifactory/laravel-svg-fixer-middleware)

The Laravel `image` validator doesn't validate an SVG if the file is missing the XML declaration on top. This middleware automatically fixes these incorrect SVG files by adding the XML declaration before it is validated.

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

[](#installation)

You can install the package via composer:

```
composer require digifactory/laravel-svg-fixer-middleware
```

Usage
-----

[](#usage)

Simply register the `SvgFixerMiddleware` class in your middleware stack.

```
// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \DigiFactory\SvgFixer\SvgFixerMiddleware::class,
    ];

    // ...
}
```

The middleware only runs for `POST` requests containing SVG files.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [DigiFactory Webworks](https://github.com/digifactory)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance85

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 56.9% 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 ~197 days

Recently: every ~183 days

Total

13

Last Release

76d ago

Major Versions

v1.0.5 → v2.0.02022-02-23

v2.0.0 → v3.0.02023-02-20

v3.0.0 → v4.0.02024-04-16

v4.1.1 → v5.0.02026-04-08

PHP version history (5 changes)v1.0.0PHP ^7.3

v1.0.5PHP ^7.4|^8.0

v2.0.0PHP ^8.0.2|^8.1

v3.0.0PHP ^8.2

v5.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e19d432d52091cec8d2004e56ea35b4142e9c638427d07a7c7646dad22f4c58?d=identicon)[digifactory](/maintainers/digifactory)

---

Top Contributors

[![m-bosch](https://avatars.githubusercontent.com/u/16580113?v=4)](https://github.com/m-bosch "m-bosch (33 commits)")[![mrk-j](https://avatars.githubusercontent.com/u/1250622?v=4)](https://github.com/mrk-j "mrk-j (23 commits)")[![StanDigiFactory](https://avatars.githubusercontent.com/u/125874113?v=4)](https://github.com/StanDigiFactory "StanDigiFactory (2 commits)")

---

Tags

middlewarelaravelsvgdigifactorylaravel-svg-fixer-middleware

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/digifactory-laravel-svg-fixer-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/digifactory-laravel-svg-fixer-middleware/health.svg)](https://phpackages.com/packages/digifactory-laravel-svg-fixer-middleware)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[sandermuller/laravel-fluent-validation

Fluent validation rule builders for Laravel

20719.0k4](/packages/sandermuller-laravel-fluent-validation)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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