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

v4.1.1(1y ago)533.2k↓45%MITPHPPHP ^8.2CI passing

Since Oct 29Pushed 1y 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 1mo ago

READMEChangelog (10)Dependencies (5)Versions (17)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

46

—

FairBetter than 93% of packages

Maintenance46

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 59.6% 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 ~198 days

Recently: every ~283 days

Total

11

Last Release

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

PHP version history (4 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

### 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 (31 commits)")[![mrk-j](https://avatars.githubusercontent.com/u/1250622?v=4)](https://github.com/mrk-j "mrk-j (19 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

[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[laravel-validation-rules/phone

Validate that a phone number is in the correct format

69355.5k](/packages/laravel-validation-rules-phone)

PHPackages © 2026

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