PHPackages                             abdur-rahaman/icon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. abdur-rahaman/icon

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

abdur-rahaman/icon
==================

Icon package for Laravel

v1.1(3w ago)14MITPHPPHP ^8.1

Since Apr 27Pushed 3w agoCompare

[ Source](https://github.com/abdurrahamanbabu/icon)[ Packagist](https://packagist.org/packages/abdur-rahaman/icon)[ RSS](/packages/abdur-rahaman-icon/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

Font Awesome 6.x Icon Package for Laravel
=========================================

[](#font-awesome-6x-icon-package-for-laravel)

A powerful Laravel package that provides seamless integration with Font Awesome 6.x icons. It includes an interactive icon picker, REST API for icon retrieval, and pre-populated database of all Font Awesome icons.

[![Laravel](https://camo.githubusercontent.com/36c92535794a8cabd7fd523cacab6ce54b1930d2819de65b69b418fdc3fca4ad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e302532422d726564)](https://camo.githubusercontent.com/36c92535794a8cabd7fd523cacab6ce54b1930d2819de65b69b418fdc3fca4ad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e302532422d726564)[![PHP](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)[![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Using Helper Functions](#using-helper-functions)
    - [Using Views](#using-views)
    - [Using the API](#using-the-api)
    - [Using the Icon Model](#using-the-icon-model)
- [Publishing Assets](#publishing-assets)
- [API Reference](#api-reference)
- [Customization](#customization)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)

---

Features
--------

[](#features)

✨ **Complete Features Include:**

- 🎨 **Pre-populated Database** - All Font Awesome 6.x icon names included
- 🔍 **Interactive Icon Picker** - Ready-to-use icon selection component
- 📡 **REST API** - Retrieve icons programmatically with search capabilities
- 🛠️ **Helper Functions** - Quick template integration with `iconAssets()` and `iconInput()`
- 🗂️ **Blade Components** - Reusable icon input form component
- 📦 **Publishable Assets** - CSS and JavaScript fully customizable
- ⚡ **One-Command Setup** - `php artisan icon:install` handles everything
- 🔄 **Auto Migration** - Database setup handled automatically
- 🎯 **Search Functionality** - Filter icons by name in real-time

---

Requirements
------------

[](#requirements)

- **PHP**: 8.1 or higher
- **Laravel**: 8.0 or higher
- **Database**: MySQL, PostgreSQL, SQLite, or any Laravel-supported database
- **Composer**: Latest version

---

Installation
------------

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require abdur-rahaman/icon
```

### Step 2: Run Installation Command

[](#step-2-run-installation-command)

The package uses Laravel's auto-discovery, so the service provider is automatically registered. Run the installation command:

```
php artisan icon:install
```

This command will:

- ✅ Publish CSS and JavaScript assets to `public/vendor/icon/`
- ✅ Publish routes to `routes/icon.php` (optional)
- ✅ Publish views to `resources/views/vendor/icon/` (optional)
- ✅ Run migrations and seed the icons database

### Step 3: Verify Installation

[](#step-3-verify-installation)

Check if assets are published:

```
ls public/vendor/icon/
```

You should see:

- `css/icon.css`
- `js/icon.js`

---

Quick Start
-----------

[](#quick-start)

### Basic Usage - Icon Picker Input

[](#basic-usage---icon-picker-input)

In your Blade template:

```
@extends('layouts.app')

@section('content')

        Select an Icon

        {!! iconInput() !!}

@endsection

@push('css')
    {!! iconAssets() !!}
@endpush
```

That's it! You now have a working icon picker.

---

Configuration
-------------

[](#configuration)

The package works out-of-the-box with zero configuration. However, here are some optional configurations:

### Custom Database Table Name

[](#custom-database-table-name)

If you need to use a different table name, publish and modify the migration:

```
php artisan vendor:publish --tag=icon-migrations
```

Then update the migration before running `php artisan migrate`.

### Custom Asset Path

[](#custom-asset-path)

Assets are published to `public/vendor/icon/` by default. To customize:

```
php artisan vendor:publish --tag=icon-assets --force
```

Then modify the paths in your Blade templates as needed.

---

Usage
-----

[](#usage)

### 1. Using Helper Functions

[](#1-using-helper-functions)

The package provides two convenient helper functions:

#### `iconAssets()` - Load CSS and JavaScript

[](#iconassets---load-css-and-javascript)

```

@push('css')
    {!! iconAssets() !!}
@endpush
```

This includes:

- Font Awesome 6.x CSS
- Icon picker JavaScript
- Hidden input with API endpoint URL

#### `iconInput()` - Icon Picker Component

[](#iconinput---icon-picker-component)

```

    @csrf
    {!! iconInput() !!}
    Save Icon

```

Renders a complete icon input field with:

- Text input for icon search/display
- Interactive icon preview/selector
- Icon showcase display area

### 2. Using Views Directly

[](#2-using-views-directly)

If you prefer more control, use the views directly:

```
@extends('layouts.app')

@section('content')

        Choose Icon:
        @include('icon::input')

@endsection
```

### 3. Using the API

[](#3-using-the-api)

The package provides a REST API endpoint for fetching icons:

#### Get All Icons (First 100)

[](#get-all-icons-first-100)

```
curl http://yourapp.test/icon/get
```

**Response:**

```
[
    {"id": 1, "icon": "fa-home", "created_at": "2026-04-28...", "updated_at": "2026-04-28..."},
    {"id": 2, "icon": "fa-user", "created_at": "2026-04-28...", "updated_at": "2026-04-28..."},
    ...
]
```

#### Search Icons

[](#search-icons)

```
curl "http://yourapp.test/icon/get?icon=home"
```

**Response:**

```
[
    {"id": 1, "icon": "fa-home", "created_at": "2026-04-28...", "updated_at": "2026-04-28..."},
    {"id": 15, "icon": "fa-home-lg-alt", "created_at": "2026-04-28...", "updated_at": "2026-04-28..."}
]
```

#### JavaScript Example

[](#javascript-example)

```
// Fetch all icons
fetch('/icon/get')
    .then(response => response.json())
    .then(data => console.log(data));

// Search for icons
fetch('/icon/get?icon=user')
    .then(response => response.json())
    .then(data => console.log(data));
```

### 4. Using the Icon Model

[](#4-using-the-icon-model)

Access icons programmatically:

```
