New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

digifactory/laravel-svg-fixer-middleware

Fixes your uploaded SVG files before validating through the Laravel validator
35,597 5
Install
composer require digifactory/laravel-svg-fixer-middleware
Latest Version:v5.0.1
PHP:^8.3
Laravel:12 · 13
Older releases:6 – 11
License:MIT
Last Updated:Apr 19, 2026
Links: GitHub  ·  Packagist
Maintainer: digifactory

Fix 'invalid' SVG files

Latest Version on Packagist MIT Licensed run-tests Quality Score StyleCI Total Downloads

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

You can install the package via composer:

composer require digifactory/laravel-svg-fixer-middleware

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

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

shin1x1/laravel-force-https-url-scheme

Force https url schema middleware for Laravel 5

26,582 25
digifactory/laravel-pull-production-data

Pull your production storage folder and database to your local environment

17,721 12
digifactory/laravel-cookie-consent

Easily deal with cookie consent in your Laravel applications

16,922 9
laravel-dev-common/union-middleware

Laravel dev middleware util

95 0
fsy-laravel/middleware-checklogin

Laravel dev mid_checklogin util

55 0

Version History

Version Released PHP Laravel License
v5.0.1 ^8.3 ^12.0|^13.0 MIT
v5.0.0 ^8.3 ^12.0|^13.0 MIT
v4.1.1 ^8.2 ^11.0|^12.0 MIT
v4.1.0 ^8.2 ^11.0|^12.0 MIT
v4.0.0 ^8.2 ^11.0 MIT