arindam/svg
Laravel package to convert raw SVG markup into .svg files. Save with optional filename, download as a response, or render directly with correct SVG content-type. Supports Laravel with/without package auto-discovery via service provider and facade.
imagick, gd, or svg2img libraries) for production-grade use.gd, imagick, or libvips for image conversion. These are common but may need enabling on shared hosting or legacy systems.SVG) and Blade directive (@svg) for simplicity, but lacks a robust CLI or queueable job interface. This may limit use cases requiring async processing (e.g., bulk conversions).spatie/svg-optimizer + imagick) would be straightforward but may require rework.canvas API) or static asset generation.gd/imagick available in the deployment environment? If not, can libvips or a fallback (e.g., headless Chrome) be used?spatie/svg-optimizer (for optimization + conversion).barryvdh/laravel-snappy (if PDF/SVG-to-PNG is needed).svg-to-png JS libraries).config/app.php.@svg in views for inline rendering.SVG::convert() or SVG::download() in controllers/middleware.Response class for downloads, ensuring consistency with existing file responses.imagick (best quality/speed) > gd (fallback) > libvips (modern alternative).storage/app/public or custom paths. Ensure proper symlinking (php artisan storage:link) if using public URLs.composer require arindam/svg) and test with sample SVGs in a staging environment.Cache::remember) for frequently accessed SVGs.spatie/svg-optimizer.composer.json overrides if needed:
"extra": {
"laravel": {
"minimum-stability": "dev",
"prefer-stable": true,
"versions": ["10.*"]
}
}
imagick may not support all SVG features like filters or scripts).ext-svg or Sabberworm/PHP-SVG for preprocessing if needed.config/services.php.@svg('path/to/svg.svg', 'logo', ['width' => 200, 'format' => 'png'])
/api/svg/{id}/download).public function downloadSvg($id) {
$svg = SVG::convert(storage_path("app/svgs/{$id}.svg"));
return SVG::download($svg, "custom-{$id}.png");
}
composer.json to avoid surprises:
"arindam/svg": "1.0.0"
imagick/gd versions in the deployment environment. Use Docker or platform-specific configs (e.g., php.ini) to enable extensions.$this->app->extend('svg', function ($svg) {
$svg->addWatermark('path/to/watermark.png');
return $svg;
});
gd/imagick are disabled.memory_limit in php.ini if converting large SVGs.dd() or Laravel’s Log facade to inspect SVG content before conversion.imagick logging for detailed errors.How can I help you explore Laravel packages today?