承接 orchid/blade-icons 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

orchid/blade-icons

最新稳定版本:4.3.0

Composer 安装命令:

composer require orchid/blade-icons

包简介

An easy way inline SVG images in your Blade templates.

README 文档

README

Packagist Packagist Version

This package for the Laravel framework allows you to use Blade components to insert inline SVG images.

Installation

To install this package, run the following command in your command line:

$ composer require orchid/blade-icons

Basic Usage

To register a directory with your files in the service provider, use the following code:

namespace App\Providers;

use Orchid\Icons\IconFinder;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(IconFinder $iconFinder) : void
    {
        $iconFinder->registerIconDirectory('fa', storage_path('app/fontawesome'));
    }
}

When calling the directory method with the first argument, we pass the prefix to call our icons and the second argument is the directory where they are located.

After that, we can call the component in our blade templates:

<x-orchid-icon path="fa.home" />

If you use one or two sets of icons that do not repeat, then it is not necessary to specify a prefix in the component:

<x-orchid-icon path="home" />

You can also list some attributes that should be applied to your icon:

<x-orchid-icon 
    path="home" 
    class="icon-big" 
    width="2em" 
    height="2em" />

Static call from a PHP class:

IconComponent::make(
    path: 'fa.home',
    id: 101,
    class: 'red',
);

Default Sizes

If you are using icons from the same set, it makes sense to specify a default size value:

namespace App\Providers;

use Orchid\Icons\IconFinder;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(IconFinder $iconFinder): void
    {
        $iconFinder
            ->registerIconDirectory('fa', storage_path('app/fontawesome'))
            ->setSize('54px', '54px');
    }
}

If you use different sets, for example, in the public part of the application and in the admin panel, then you can dynamically change the value in the middleware:

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Orchid\Icons\IconFinder;

class ExampleMiddleware
{
    public function __construct(
        private IconFinder $iconFinder
    ) {}

    /**
     * Handle an incoming request.
     */
    public function handle(Request $request, Closure $next): mixed
    {
        $this->iconFinder->setSize('54px', '54px');

        return $next($request);
    }
}

统计信息

  • 总下载量: 3.31M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 1
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04