Migrating from PHP

oxblade-icons Alpha Rust

This page lists each blade-ui-kit/blade-icons call and its Rust equivalent, for code moving from PHP.

Calls

PHPRust
svg('heroicon-o-home')icons.icon("heroicon-o-home")?
svg('heroicon-o-home', 'size-6')icons.svg("heroicon-o-home", "size-6", Attributes::new())?
svg('heroicon-o-home', ['width' => 24])icons.svg_with("heroicon-o-home", Attributes::new().set("width", 24))?
svg('heroicon-o-home', 'size-6', ['width' => 24])icons.svg("heroicon-o-home", "size-6", Attributes::new().set("width", 24))?
['x-cloak'] (value without a key)Attributes::new().flag("x-cloak")
->toHtml().to_html()
->strokeWidth(2).attr("stroke-width", 2)?
->name(), ->contents(), ->attributes().name(), .contents(), .attributes()
app(Factory::class)->all()icons.sets()
app(Factory::class)->add('name', [...])Icons::builder().set(IconSet::from_static(...))

Templates

PHP Bladeoxblade
{{ svg('heroicon-o-home', 'size-6') }}the same
@svg('heroicon-o-home', 'size-6')the same
<x-icon name="heroicon-o-home" class="size-6" />the same
<x-heroicon-o-home class="size-6" />the same
<x-heroicon-o-home defer />not supported (Error::Deferred)

See Blade templates to register them.

Configuration

PHP config/blade-icons.phpRust
sets.heroicons.path.set(icon_set!(oxblade_heroicons)) or IconSet::from_static
sets.default.path = 'resources/svg'a set named default (see Icon sets)
sets.*.prefixthe second argument of IconSet::from_static / from_lookup
sets.*.class, attributes, fallbackIconSet::class, attributes, fallback, or SetConfig
class, attributes, fallbackIconsBuilder::class, attributes, fallback, or IconsConfig
components.defaultblade::Options::icon_component(Some("…"))
components.disabled = trueOptions::new().set_components(false)
php artisan icons:cache, icons:clearnot needed; sets are compiled in

The installation package for a set, such as blade-ui-kit/blade-heroicons, becomes a data crate such as oxblade-heroicons from oxblade-icon-sets.

Behaviour to check

  • A title from a plain string is escaped inside <title>; use Trusted(...) for PHP's exact output.
  • to_html() doesn't add a second title when called twice.
  • Attribute names starting with on are rejected.
  • Fallbacks must exist when the registry is built.

The README's Differences from PHP section lists each difference with its reason.