agenticmorf/fluxui-avatar
Composer 安装命令:
composer require agenticmorf/fluxui-avatar
包简介
A drop-in, highly configurable Avatar Manager for Laravel applications using Livewire 4 and Flux UI.
README 文档
README
A drop-in, highly configurable Avatar Manager for Laravel applications using Livewire 4 and Flux UI.
This package seamlessly handles the uploading, validating, storing, and displaying of user avatars while non-invasively injecting itself into the Flux UI Livewire Laravel starter kit. No vendor publishing. No editing starter-kit files. Just install and go.
What It Does
- 🖼️ Display — Automatically resolves the authenticated user's avatar everywhere
<flux:avatar />is used, with a graceful fallback to auto-generated initials. - ⬆️ Upload — A ready-to-use
<livewire:avatar-manager />component with Flux UI file-upload styling, loading states, and validation. - 🗄️ Store — Two built-in storage adapters: Laravel Filesystem (disk) and Spatie Media Library.
- 🔌 Non-invasive — View namespace shadowing means the starter kit's profile header magically shows the correct avatar without any code changes.
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 |
| Livewire | ^4.0 |
| Flux UI | Latest starter kit |
Installation
Install via Composer:
composer require agenticmorf/fluxui-avatar
Laravel's package auto-discovery will automatically register the service provider.
Publish the Config
php artisan vendor:publish --tag=fluxui-avatar-config
This creates config/fluxui-avatar.php.
Configuration
// config/fluxui-avatar.php return [ // 'spatie' or 'disk' 'driver' => env('FLUXUI_AVATAR_DRIVER', 'disk'), // Spatie driver settings 'spatie_collection_name' => 'avatars', // Disk driver settings 'disk' => env('FLUXUI_AVATAR_DISK', 'public'), 'directory' => 'avatars', 'column' => 'avatar_path', // DB column on your User model // Validation 'accepted_types' => ['jpg', 'jpeg', 'png', 'webp'], 'max_file_size' => 2048, // in KB // Default avatar URL (null uses Flux UI's built-in fallback) 'default_avatar' => null, ];
Switching Drivers
Disk driver (default): Uses Laravel's filesystem. Add avatar_path to your users table:
php artisan make:migration add_avatar_path_to_users_table
$table->string('avatar_path')->nullable();
Spatie driver: Requires spatie/laravel-medialibrary. Add HasMedia to your User model:
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; class User extends Authenticatable implements HasMedia { use InteractsWithMedia; public function registerMediaCollections(): void { $this->addMediaCollection('avatars')->singleFile(); } }
Then update your .env:
FLUXUI_AVATAR_DRIVER=spatie
Usage
Drop the Component Into Your Profile Page
Place the Livewire component wherever you want the avatar upload form to appear (e.g., resources/views/profile.blade.php):
<livewire:avatar-manager />
That's it. The component handles everything — upload, preview, validation, removal.
The Header Avatar "Just Works"
Anywhere in the Flux UI starter kit that renders <flux:avatar />, this package's shadowed component will automatically inject the authenticated user's avatar URL. If no avatar has been uploaded, it gracefully falls back to generated initials from the user's name.
You don't need to change any starter-kit views.
Under the Hood: The View Overload Magic
Flux UI registers its components under the flux Blade namespace. Laravel resolves these components by searching all paths registered for that namespace, in order.
This package's FluxuiAvatarServiceProvider::boot() method calls:
$viewFactory->prependNamespace('flux', __DIR__.'/../resources/views/components');
prependNamespace inserts our path at the front of the namespace's path list, so when Laravel resolves <flux:avatar />, it finds our resources/views/components/avatar.blade.php first.
Our avatar.blade.php resolves the current user's avatar from the configured storage adapter, generates initials if needed, then delegates to Flux's real template (flux::avatar.index from the livewire/flux package). We cannot nest <flux:avatar> here: namespace shadowing would resolve to this same file and recurse infinitely. Including the vendor view preserves all native Flux UI avatar behavior.
Available Props for <flux:avatar>
This package augments Flux's avatar component: when src is omitted, it fills the URL (and optionally initials) from the authenticated user. All Flux Avatar props continue to work (size, circle, color, name, icon, badge, tooltip, and so on). If you pass shape="circle" or shape="square", it is mapped to Flux's circle boolean for compatibility with older examples.
Testing
# Run the full test suite composer test # Run with coverage report composer test-coverage # Run static analysis composer analyse # Check code style composer format
Changelog
Please see CHANGELOG.md for recent changes.
License
The MIT License (MIT). Please see LICENSE for more information.
agenticmorf/fluxui-avatar 适用场景与选型建议
agenticmorf/fluxui-avatar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「avatar」 「file-upload」 「livewire」 「flux-ui」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 agenticmorf/fluxui-avatar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 agenticmorf/fluxui-avatar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 agenticmorf/fluxui-avatar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generate an Adorable Avatar for Laravel
Change the default avatar url provider with one for inline SVGs
Integrates the rekalogika/file library into the Symfony framework.
Upload files using Symfony Form, FilePond, and the rekalogika/file framework
A powerful chunked file upload field for Filament using Uppy.js with S3, remote sources (Google Drive, OneDrive, Dropbox), webcam, screen capture, audio recording, image editing and more.
Symfony bundle for automatic file upload handling on Doctrine ORM entities with S3, CDN, and multiple storage support
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-17