- How do I install and use Phosphor Icons in Laravel Blade?
- Run `composer require codeat3/blade-phosphor-icons:^2.0` for Phosphor Icons v2 (or `^1.0` for v1). Use Blade components like `<x-phosphor-alarm/>` or `<x-phosphor-users class='w-6 h-6' />` in your views. The package auto-generates SVG icons on demand.
- Does this package support Laravel 13?
- Yes, the package explicitly supports Laravel 13 and includes optimizations for modern Laravel features. Check the [release notes](https://github.com/codeat3/blade-phosphor-icons/releases) for compatibility details.
- How can I cache icons for better performance?
- Run `php artisan icons:cache` during deployment to pre-generate icons. Use Blade’s `@cache` directive for dynamic caching, e.g., `@cache(['tags' => 'dashboard-icons'], 60) @phosphor('users') @endcache`. Refer to the [Blade Icons caching guide](https://github.com/driesvints/blade-icons#caching) for advanced setups.
- Can I customize default icon attributes globally?
- Yes, publish the config file with `php artisan vendor:publish --tag=blade-phosphor-icons-config` to set defaults like `default_classes`, `default_attributes`, or `icon_set`. This avoids repeating attributes in every Blade component.
- What happens if the Phosphor CDN fails in production?
- The package includes local SVG assets by default, so icons will still render even if the CDN is unavailable. No additional configuration is needed—fallbacks are handled automatically.
- Does this work with Livewire or Inertia.js?
- No, this package is Blade-focused and won’t work directly in Livewire/Inertia.js components. For those cases, manually include Phosphor SVGs or use a frontend library like `@phosphor-icons/react`.
- How do I upgrade from v1 to v2?
- Follow the [upgrade guide](UPGRADE.md) in the repo. Key steps include updating Composer (`^2.0`), clearing Blade cache (`php artisan view:clear`), and testing dynamic icons. The package maintains backward compatibility for most use cases.
- Can I use dynamic icon names (e.g., `@phosphor($dynamicIcon)`)?
- Yes, dynamic icons are supported, but ensure the variable is sanitized to avoid Blade injection risks. For caching, use `@cache` with unique tags (e.g., `@cache(['tags' => 'user-'.$userId])`) to prevent stale content.
- Does this integrate with Vite or Laravel Mix for SVG optimization?
- The package outputs inline SVGs, so Vite/Laravel Mix won’t auto-optimize them. For production, manually configure Vite to inline critical icons or lazy-load non-critical ones. HTTP caching (e.g., `Cache-Control: immutable`) for SVG assets is recommended.
- Are there alternatives to this package?
- For Laravel, alternatives include manually including Phosphor SVGs or using `blade-icons` directly. For broader use, consider `@phosphor-icons/react` (frontend) or `laravel-svg` (for SVG asset management). This package stands out for its Blade integration and caching optimizations.