artisanpack-ui/icons
Register and use your own SVG icon sets in Laravel with minimal overhead. Integrates with blade-ui-kit/blade-icons and Livewire UI, supports config or event-based registration, and makes it easy to add premium sets like Font Awesome Pro.
Installation:
composer require artisanpack-ui/icons
php artisan vendor:publish --tag=artisanpack-package-config
First Use Case:
resources/icons/[set-name]/ (e.g., resources/icons/fontawesome-pro/home.svg).config/artisanpack/icons.php:
'sets' => [
'fa' => [
'path' => resource_path('icons/fontawesome-pro'),
'prefix' => 'fa',
],
],
<x-icon-fa-home class="w-6 h-6" />
Where to Look First:
config/artisanpack/icons.php for configuration.resources/icons/ for organizing your SVG files.config/artisanpack/icons.php for static, project-wide icons.'sets' => [
'hero' => [
'path' => resource_path('icons/heroicons'),
'prefix' => 'hero',
],
'custom' => [
'path' => resource_path('icons/custom'),
'prefix' => 'custom',
'disk' => 's3', // Optional: Use a custom filesystem disk
],
],
ap.icons.register-icon-sets filter in a Service Provider or Event Listener.// In a Service Provider's `boot()` method
addFilter('ap.icons.register-icon-sets', function (IconSetRegistration $registry) {
$registry->addSet(__DIR__ . '/../../resources/icons', 'mypackage');
return $registry;
});
addFilter('ap.icons.register-icon-sets', function ($sets) {
if (auth()->check() && auth()->user()->is_admin) {
$sets[] = new IconSetRegistration(
path: __DIR__ . '/../../resources/icons/admin',
prefix: 'admin'
);
}
return $sets;
});
<!-- In a Livewire component -->
<x-icon-fa-home class="w-6 h-6" wire:click="goHome" />
blade-ui-kit/blade-icons for consistent icon rendering across your app.resources/icons/auth/, resources/icons/dashboard/) and register them with descriptive prefixes.'sets' => [
'auth' => [
'path' => resource_path('icons/auth'),
'prefix' => 'auth',
],
'dashboard' => [
'path' => resource_path('icons/dashboard'),
'prefix' => 'dashboard',
],
],
'sets' => [
'cloud' => [
'path' => 'icons/cloud', // Relative to storage path
'prefix' => 'cloud',
'disk' => 's3',
],
],
Prefix Conflicts:
admin) will overwrite each other.myapp-admin, plugin-x-admin).config/artisanpack/icons.php and event-driven registrations for duplicates.Missing SVG Files:
config/artisanpack/icons.php and ensure files exist at the specified location.ArtisanPackUI\Icons\Facades\Icons::getSets() to inspect registered sets.Caching Issues:
php artisan view:clear
'cache' => env('APP_ENV') !== 'local',
in config/artisanpack/icons.php.Filesystem Permissions:
config/filesystems.php and the package has access.Case Sensitivity:
home.svg vs. Home.svg).user-profile.svg).Inspect Registered Sets:
use ArtisanPackUI\Icons\Facades\Icons;
dd(Icons::getSets());
Check Icon Existence:
if (!Icons::hasIcon('fa', 'home')) {
\Log::error('Icon "fa-home" not found!');
}
Enable Debug Logging:
Add to config/artisanpack/icons.php:
'debug' => env('APP_ENV') === 'local',
storage/logs/laravel.log.Custom Icon Resolvers:
use ArtisanPackUI\Icons\Contracts\IconResolver;
class FontAwesomeResolver implements IconResolver { ... }
ap.icons.register-resolvers filter.Dynamic Icon Generation:
ap.icons.generate-icon event to dynamically create icons from data (e.g., emoji or generated SVGs).Icon Theming:
<x-icon-fa-home class="text-blue-500" />
<x-my-icon.primary name="fa-home" />
Lazy Loading:
Minimize Disk I/O:
disk: null) unless remote storage is required.Bundle Icons:
Default Values:
disk is not specified, the package defaults to the local filesystem.prefix is omitted, it defaults to the set name (e.g., path: 'icons/hero' → prefix: 'hero').Path Resolution:
app_path(), resource_path(), etc.).addSet(realpath(__DIR__ . '/../../resources/icons'), 'mypackage');
Environment-Specific Config:
config/artisanpack/icons-local.php) and merge it:
$config = require __DIR__ . '/icons.php';
if (file_exists($customConfig = __DIR__ . '/icons-' . env('APP_ENV') . '.php')) {
$config = array_merge_recursive($config, require $customConfig);
How can I help you explore Laravel packages today?