Skip to content

Cache & Utilities

These commands help with day-to-day operations: clearing the cache, pre-warming icons for production, listing what’s available, and scaffolding a new config file.

cache:clear wipes all cached icon files from disk and reports how much space was freed:

Terminal window
vendor/bin/swarm-icons cache:clear
vendor/bin/swarm-icons cache:clear --path=/var/cache/icons
OptionShortDefault
--path-psys_get_temp_dir()/swarm-icons
[OK] Cache cleared successfully!
Removed 142 cached files (856.3 KB)
Location: /tmp/swarm-icons

If you’re using the Iconify API provider in production and want zero HTTP requests at runtime, cache:warm pre-fetches icons during deployment. It batches everything into a single request:

Terminal window
vendor/bin/swarm-icons cache:warm --prefix=tabler --icons=home,user,settings,arrow-left
OptionShortDescriptionDefault
--prefix-pIcon set prefix (required)-
--icons-iComma-separated icon names (required)-
--cache-pathCache directorysys_get_temp_dir()/swarm-icons
--timeout-tHTTP timeout in seconds10
[OK] Warmed 4 icon(s) for prefix 'tabler'
All icons fetched successfully
Cache now contains 146 files (862.1 KB)

If some icons can’t be found, the command tells you which ones failed and still caches the rest.

icon:list shows what icons are available from a local directory or an Iconify set:

Terminal window
# From a local SVG directory
vendor/bin/swarm-icons icon:list --path=/path/to/svgs
# From an Iconify set (fetches from API)
vendor/bin/swarm-icons icon:list --prefix=tabler --iconify
# Filter by name
vendor/bin/swarm-icons icon:list --prefix=heroicons --iconify --search=chevron
OptionShortDescriptionDefault
--prefix-pIcon set prefix (for Iconify mode)-
--pathPath to local SVG directory-
--iconifyFetch from Iconify API instead of local filesfalse
--search-sFilter by substring-

Local mode (--path) works offline and is instant. Iconify mode (--prefix + --iconify) needs network access.

init creates a swarm-icons.php file with commented examples for every option: providers, cache, defaults, and the global helper. Uncomment what you need and you’re ready to go:

Terminal window
vendor/bin/swarm-icons init
vendor/bin/swarm-icons init --output=config/swarm-icons.php
vendor/bin/swarm-icons init --force # overwrite an existing file
OptionShortDefault
--output-oswarm-icons.php
--force-ffalse

The generated file looks like this:

<?php
use Frostybee\SwarmIcons\SwarmIcons;
use Frostybee\SwarmIcons\SwarmIconsConfig;
$manager = SwarmIconsConfig::create()
// Icon Providers
// ->addDirectory('custom', __DIR__ . '/resources/icons')
// ->addIconifySet('tabler')
// ->addHybridSet('heroicons', __DIR__ . '/resources/heroicons')
// ->discoverPackages()
// Cache
->cachePath(__DIR__ . '/cache/icons')
// Defaults
// ->defaultPrefix('tabler')
// ->defaultAttributes(['class' => 'icon'])
// ->fallbackIcon('tabler:question-mark')
->build();
SwarmIcons::setManager($manager);
return $manager;