Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spatie Laravel Google Fonts Plugin Laravel Package

filament/spatie-laravel-google-fonts-plugin

Adds a Spatie Google Fonts provider to Filament panels, letting you use locally fetched and cached Google Fonts via spatie/laravel-google-fonts. Configure with Panel::font('Inter', provider: SpatieGoogleFontProvider::class) to avoid CDNs.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Frontend Integration: The package extends Filament’s typography system by integrating Spatie’s Google Fonts caching mechanism, replacing CDN-based font loading with locally cached assets. This aligns well with Filament’s modular architecture, where plugins extend core functionality (e.g., Panel::font()).
  • Backend/Storage Fit: Leverages Spatie’s existing caching logic (e.g., @googlefonts Blade directive), reducing redundant font-fetching logic in Filament. The plugin acts as a thin wrapper, minimizing custom backend changes.
  • Design System Compatibility: Ideal for projects using Filament’s admin panel where consistent typography is critical (e.g., dashboards, SaaS apps). Fonts are served via Filament’s asset pipeline, ensuring consistency with other CSS/JS assets.

Integration Feasibility

  • Low Coupling: The plugin requires only Spatie’s package (spatie/laravel-google-fonts) and Filament’s core. No database migrations or complex dependencies are introduced.
  • Configuration Override: Fonts are configured via Panel::font(), a Filament-native method, reducing friction for teams already using Filament’s panel system.
  • Asset Pipeline: Fonts are injected via Blade directives (@googlefonts), which integrate seamlessly with Laravel Mix/Vite if used.

Technical Risk

  • Dependency on Spatie’s Package: Requires prior setup of spatie/laravel-google-fonts (e.g., storage paths, caching, API keys). Misconfiguration here could break font loading.
  • Caching Overhead: Spatie’s package caches fonts locally, which may increase storage usage for projects with many fonts/variants (e.g., Inter:wght@100..900).
  • Blade Directive Limitation: The @googlefonts directive is Blade-specific, which could complicate projects using non-Blade templating (e.g., Inertia.js with Vue/React).
  • Version Alignment: Must align filament/spatie-laravel-google-fonts-plugin (v5.x) with compatible Filament and Spatie versions (e.g., Filament v3.x+).

Key Questions

  1. Font Variants: How will the team handle font variant selection (e.g., weights, styles)? Will Spatie’s caching scale for large variant sets?
  2. Fallback Mechanisms: What’s the fallback if Google Fonts API fails or caching corrupts? Does Spatie’s package support CDN fallbacks?
  3. Performance Impact: How will locally cached fonts compare to CDN performance in terms of load times and TTFF (Time to First Font)?
  4. Multi-Panel Support: If using multiple Filament panels, how will font configurations be shared/isolated?
  5. Custom Fonts: Can this plugin coexist with custom self-hosted fonts (e.g., WOFF2 files in public/fonts)?
  6. Testing: Are there existing tests for edge cases (e.g., missing API keys, invalid font names)?

Integration Approach

Stack Fit

  • Primary Use Case: Best suited for Filament-based admin panels where Google Fonts are used for typography (e.g., Inter, Roboto). Avoid for projects requiring offline-first or self-hosted fonts exclusively.
  • Tech Stack Compatibility:
    • Laravel: Requires Laravel 9+ (for Spatie’s package) and Filament v3+.
    • Frontend: Works with Blade, Inertia.js (if using Blade views), or Livewire. Non-Blade setups may need custom directive handling.
    • Asset Builders: Compatible with Laravel Mix, Vite, or Inertia’s asset pipeline (no direct conflicts).
  • Alternatives Considered: Self-hosting fonts (e.g., WOFF2 files) or using Filament’s native font() with CDN URLs. This plugin reduces CDN dependency but adds caching complexity.

Migration Path

  1. Prerequisite Setup:
    • Install spatie/laravel-google-fonts (follow Spatie’s docs).
    • Configure Google Fonts API key, storage paths, and caching in .env and config/google-fonts.php.
  2. Plugin Installation:
    composer require filament/spatie-laravel-google-fonts-plugin:"^5.0" -W
    
  3. Panel Configuration: Update app/Providers/Filament/PanelProvider.php to use the provider:
    ->font('Inter', provider: SpatieGoogleFontProvider::class)
    
  4. Testing:
    • Verify fonts render in Filament panels.
    • Check cached fonts in storage/app/public/google-fonts.
  5. Optional: Extend for dynamic font selection (e.g., via user preferences) by overriding the provider.

Compatibility

  • Filament Versions: Confirmed compatible with Filament v3.x. Check for v2.x support if legacy.
  • Spatie Version: Requires spatie/laravel-google-fonts v3.x+. Avoid mixing with older versions.
  • Blade Dependency: Critical for @googlefonts directive. Projects using server-side rendering (SSR) with Blade will work; SPA setups (e.g., Inertia + Vue) may need additional handling.
  • Caching Systems: Works with Laravel’s default caching (file, Redis) or Spatie’s custom cache. No conflicts with other caching layers.

Sequencing

  1. Phase 1: Set up Spatie’s package (highest risk, longest setup).
  2. Phase 2: Install and configure the Filament plugin (low risk).
  3. Phase 3: Test in staging with real font variants (e.g., Inter:wght@400;700).
  4. Phase 4: Monitor caching behavior and performance in production.

Operational Impact

Maintenance

  • Plugin Updates: Minor updates (e.g., v5.x patches) are low-effort. Major versions may require Filament/Spatie compatibility checks.
  • Spatie Dependency: Maintenance burden shifts to Spatie’s package (e.g., API key rotations, caching logic). Monitor their release notes.
  • Font Management: Adding/removing fonts requires updating Spatie’s config and re-caching (e.g., php artisan google-fonts:cache).
  • Logging: Limited built-in logging. May need to extend Spatie’s package for debug logs (e.g., failed API requests).

Support

  • Troubleshooting:
    • Font Loading Failures: Check Spatie’s cache directory (storage/app/public/google-fonts) and Laravel logs.
    • API Issues: Validate Google Fonts API key and quota limits.
    • Blade Directive Errors: Ensure @googlefonts is used within Filament’s asset pipeline.
  • Community Resources: Limited to Filament/Spatie docs. May require opening issues for plugin-specific bugs.
  • Fallback Support: No built-in fallback to CDN or local files. Requires custom logic if needed.

Scaling

  • Font Variants: Caching scales linearly with font variants. Large projects (e.g., 50+ variants) may need optimized storage (e.g., S3 for cached fonts).
  • Multi-Tenant: Spatie’s package supports multi-tenancy via API keys. Ensure keys are isolated per tenant.
  • Performance:
    • Initial Load: First load may be slower due to caching (mitigate with CDN fallback during setup).
    • Subsequent Loads: Local caching reduces latency; no CDN dependency.
  • Asset Pipeline: No impact on scaling unless mixing with other asset-heavy plugins (e.g., Filament Media Library).

Failure Modes

Failure Scenario Impact Mitigation
Google Fonts API key invalid/expired Fonts fail to load Monitor API key validity; set up alerts.
Storage permissions issue Cached fonts inaccessible Ensure storage/app/public/google-fonts is writable.
Spatie package misconfiguration No fonts rendered Validate config/google-fonts.php and cache.
Blade directive not found Fonts missing in non-Blade views Use CDN fallback or custom provider.
High font variant count Storage bloat Prune unused variants or use S3 caching.
Filament/Spatie version conflict Plugin breaks Pin versions in composer.json.

Ramp-Up

  • Developer Onboarding:
    • Time Estimate: 1–2 hours for setup (assuming Spatie’s package is pre-configured).
    • Key Steps: Install plugin, configure Panel::font(), test in a local Filament panel.
  • Documentation Gaps:
    • Limited examples for dynamic font selection or multi-panel setups.
    • No guidance on handling API rate limits or caching invalidation.
  • Training Needs:
    • Familiarity with Spatie’s package required (e.g., caching commands, config).
    • Filament panel configuration basics assumed.
  • Rollback Plan:
    • Revert to CDN-based fonts by removing the plugin and using Panel::font('Inter') without
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle