abetwothree/laravel-iconify-api

A package to create a local API for the dynamic Iconify Icon components

v1.2.0 2025-05-05 12:50 UTC

This package is auto-updated.

Last update: 2025-05-12 02:03:08 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Make your Laravel Application an API for on demand icons using the Iconify icon web components.

This Laravel package creates a few API routes for the Iconify icons on demand API. It allows you to easily use on demand icons and use your Laravel applicatioin as the Iconify API.

It works similarly to the Node Iconify API and is a spiritual successor to their PHP implementation.

On demand icons work great whether you use Livewire, Inertia, or just plain Blade views to render your Laravel application and want to render icons dynamically using a single component.

Requirements

  • PHP 8.4
  • Laravel 12.x or 11.x

How To Use

Install the package via composer:

composer require abetwothree/laravel-iconify-api

In your core application blade layout file add the following directive in the head section before your application's JS bundle:

@iconify

This will configure the Iconify API on demand icons to load the icons from your Laravel application instead of the Iconify API.

By default Icon API routes will work out of the following route path in your Laravel application:

/iconify/api

The following routes are currently available:

  • /iconify/api/{prefix}.json?icons={icon-prefix} - Returns icon SVG data for an icon set. Icon prefix can be comma separated for multiple icons.
  • /iconify/api/{prefix}/icons.json?icons={icon-prefix} - Same as above.
  • /iconify/api/collections - Returns a list of icon collections available in your application.
  • /iconify/api/collection?prefix={prefix} - Returns the information for a specific icon collection.

How To Display Icons

To displays icons follow the instructions on the Iconify on demand docs and use any of their component libraries in your Laravel Application.

You also need icon set data to be available in your application. You'll need to install the icon set data using NPM. See more info here.

We recommend installing individual icon sets instead of the entire Iconify JSON set to keep your application lightweight. However, you can install the entire set if you wish and this package will work with either approach.

Advanced Configuration

To configure the package, you can publish the config file using the following command:

php artisan vendor:publish --tag="iconify-api-config"

This will publish a iconify-api.php file in your config directory. You can then configure the package to your liking.

For advanced setting details, please see the config file.

If you update your configuration file, make sure to break your application cache with the following commands:

php artisan config:clear
php artisan cache:clear
php artisan view:clear

Icon Caching

This package uses Laravel's caching system to cache the icon data to make repeated requests for the same icon faster. It caches icon data when it is requested so that it only caches the icons that are actually used in your application.

You can set which cache store to use for this package in your config/iconify-api.php file. Otherwise, it will use your default cache store setting.

Missing Features

The MVP of this package was to provide an API for on demand icons in your Laravel Application. A few API endpoints that currently exist on the Node JS package that are missing in this package and will be added in future releases:

  • Return icon data in in JSONP callback format.
  • List icons in a collection.
  • List icons categorized in a collection.
  • Search endpoint for icons.
  • Keywords endpoint for icons.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Code Quality

This package uses the following code quality tools:

  • PHPStan 2.x at level 10 for static analysis.
  • Laravel Pint for consistent code style.
  • PHP Pest for testing.

Credits

License

The MIT License (MIT). Please see License File for more information.