orchid/blade-icons
Composer 安装命令:
composer require orchid/blade-icons
包简介
An easy way inline SVG images in your Blade templates.
README 文档
README
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); } }
orchid/blade-icons 适用场景与选型建议
orchid/blade-icons 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.52M 次下载、GitHub Stars 达 22, 最近一次更新时间为 2020 年 06 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 orchid/blade-icons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 orchid/blade-icons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.52M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 28
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-24