fadlee/filament-qrcode-field
Composer 安装命令:
composer require fadlee/filament-qrcode-field
包简介
QR code scanner for Filament
README 文档
README
A custom form field component for Filament PHP that adds QR code scanning capabilities to your forms. This package provides a text input field with an integrated QR code scanner using the device's camera.
Features
- Seamless integration with Filament forms
- Support for multiple QR code inputs on a single page
- Compatible with Filament action modals
- Real-time QR code scanning using device camera
- Automatic camera selection (prefers rear camera if available)
- Modal interface for scanning QR code
- Uses ZXing library for reliable QR code detection
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- Filament 3.x
- HTTPS enabled environment (required for camera access)
Installation
You can install the package via composer:
composer require fadlee/filament-qrcode-field
After installation, you need to publish the package assets:
php artisan filament:assets
The package will automatically register its service provider.
Usage
- Import the QrCodeInput component in your Filament resource or form:
use Fadlee\FilamentQrCodeField\Forms\Components\QrCodeInput;
- Add the field to your form:
public static function form(Form $form): Form { return $form ->schema([ QrCodeInput::make('qrcode') ->label('QR Code') ->placeholder('Click to scan QR code...'), // ... other fields ]); }
- Using multiple QR code inputs:
public static function form(Form $form): Form { return $form ->schema([ QrCodeInput::make('product_code') ->label('Product QR Code') ->placeholder('Scan product code...'), QrCodeInput::make('location_code') ->label('Location QR Code') ->placeholder('Scan location code...'), ]); }
- Using in Filament action modals:
use Filament\Actions\Action; public static function getActions(): array { return [ Action::make('scanQR') ->form([ QrCodeInput::make('qrcode') ->label('Scan QR Code') ->required(), ]) ->action(function (array $data) { // Process the scanned QR code // $data['qrcode'] contains the scanned value }), ]; }
How it Works
The package adds QR code scanning capability to a text input field. When the input field is clicked, it opens a modal with camera access to scan QR codes. Once a QR code is successfully scanned, the value is automatically populated into the input field.
Security
- The package requires camera permissions from the user's browser
- Camera access is only activated when the scan modal is opened
- Camera is automatically stopped when the modal is closed
Technical Implementation
The QR code scanner is seamlessly integrated into Filament through several key mechanisms:
-
Modal Injection: The package automatically injects the QR code scanner modal markup at the end of each Filament page using Filament's render hooks system.
-
JavaScript Integration: The package includes a custom JavaScript component that handles the camera access and QR code scanning.
-
Event Handling: The package uses event delegation to handle QR code scanning requests. When a QR code input field is clicked, the scanner modal is automatically opened and the camera is activated.
-
Camera Access: The package uses the browser's
getUserMediaAPI to request camera access. Due to browser security policies, HTTPS is required for camera access to work. The camera is automatically selected as the rear camera if available, and the user is prompted to grant camera access.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Credits
This package was inspired by and contains code adapted from the barcode-field package by Design-The-Box. We appreciate their contribution to the Filament ecosystem.
License
This package is open-sourced software licensed under the MIT license.
fadlee/filament-qrcode-field 适用场景与选型建议
fadlee/filament-qrcode-field 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 362 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filament」 「filament-plugin」 「form-field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fadlee/filament-qrcode-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fadlee/filament-qrcode-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fadlee/filament-qrcode-field 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
jitone-ai is a powerful FilamentPHP plugin that integrates AI-powered features directly into your Filament forms.
Send Notification to discord channel Webhook using native FilamentPHP Notification Facade class
Indonesia Region Field for Filament
A Slick Slider for your filament v3 forms.
A Filament v3 form field that integrates TinyMCE 8 rich text editor with dark mode, profiles, and file browser support.
Pikaday date picker field for FilamentPHP — lightweight, dependency-light date input with min/max dates, year range, first-day-of-week, and full i18n.
统计信息
- 总下载量: 362
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-28