symfony/ux-icons
Symfony UX Icons provides a simple way to use SVG icon packs in Symfony apps. Install popular sets, render icons in Twig or PHP, and manage them consistently across your UI with the Symfony UX tooling and asset pipeline.
symfony/twig-bundle, avoiding frontend bloat.fill-current for dynamic colors).spatie/laravel-twig).Storage or HttpClient with strict validation).Cache::remember with versioned URLs).{{ ux_icon('mdi:home') }} vs. <img src="/icons/home.svg">).<twig:ux:icon name="user" class="text-red-500" />).@twig('icons/{$name}.svg')).Icon::render('home')) that internally uses Twig.Icon::svg('home')).HttpClient with allow_redirects: false and verify_peer: true.https://cdn.example.com/icons/v2/home.svg) or ETag-based caching.@icon('home') as a helper).symfony/twig-bundle:^6.4.icon_sets config for Material Icons vs. custom SVGs.Cache::remember or CDN caching).fill-current for dynamic colors vs. icon font limitations.Icon::render('home', fallback: '<span>⚙️</span>').@svg('icon.svg', { smacss: true })).<twig:ux:icon name="{{ $user.role }}" />).// app/Helpers/Icon.php
class Icon {
public static function render(string $name, array $attrs = []): string {
$twig = \Twig\Environment::create();
return $twig->render("icons/{$name}.svg.twig", $attrs);
}
}
// Blade usage: {{ Icon::render('home', ['class' => 'text-blue-500']) }}
// app/Providers/BladeServiceProvider.php
Blade::directive('icon', function ($name) {
return "<?php echo app\\Helpers\\Icon::render({$name}); ?>";
});
// Blade usage: @icon('home')
php artisan icon:cache).Phase 1: Assessment (1 day)
Phase 2: Setup (2–3 days)
composer require symfony/ux-icons symfony/twig-bundle
config/packages/twig.php:
twig:
paths: ['%kernel.project_dir%/templates/icons']
globals:
icon_sets: ['mdi', 'heroicons']
templates/icons/base.svg.twig):
<svg viewBox="0 0 24 24" fill="currentColor" {# attributes #}>
{# Icon content (rendered dynamically) #}
</svg>
Phase 3: Icon System (1 week)
/resources/svg/icons/
├── mdi/
│ ├── home.svg
│ └── user.svg
└── heroicons/
├── outline/
│ └── home.svg
└── solid/
└── user.svg
templates/icons/mdi/home.svg.twig):
{% extends 'icons/base.svg.twig' %}
{% block icon_content %}
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
{% endblock %}
app/Services/IconService.php) for Blade compatibility:
class IconService {
public function render(string $name, array $attrs = []): string {
$twig = \Twig\Environment::create();
return $twig->render("icons/{$name}.svg.twig", $attrs);
}
}
Phase 4: Integration (2 weeks)
How can I help you explore Laravel packages today?