digifactory / laravel-svg-fixer-middleware
Fixes your uploaded SVG files before validating through the Laravel validator
Installs: 30 995
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/digifactory/laravel-svg-fixer-middleware
Requires
- php: ^8.2
- illuminate/http: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- illuminate/validation: ^11.0|^12.0
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
This package is auto-updated.
Last update: 2025-10-04 13:57:06 UTC
README
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.