laravel-enso/avatarmanager
最新稳定版本:4.5.7
Composer 安装命令:
composer require laravel-enso/avatarmanager
包简介
User Avatar manager dependency for Laravel Enso
README 文档
README
Description
Avatars is Laravel Enso's user avatar package.
It attaches one avatar record to each user, exposes authenticated endpoints for viewing, uploading, and regenerating avatars, and integrates with Enso's file pipeline so custom uploads are stored and transformed consistently.
The package also generates default avatars automatically. It prefers Gravatar when a public image exists for the user's email address and falls back to a locally generated Laravolt avatar when it does not.
The frontend integration lives primarily in the Enso user profile experience and reusable avatar components from @enso-ui/users.
Installation
This package comes pre-installed in Laravel Enso applications that support user profile avatars.
For standalone installation in an Enso-based application:
composer require laravel-enso/avatars
The package auto-registers its service providers, loads migrations, registers API routes, observes user creation, and exposes the avatar generation command.
Run the migrations after installation:
php artisan migrate
If you need the package storage scaffolding, publish it with:
php artisan vendor:publish --tag=avatars-storage
Features
- Adds a one-to-one avatar relation to
LaravelEnso\Users\Models\Userthrough dynamic methods. - Adds a
generateAvatar()dynamic method to users for regenerating their default avatar. - Generates a default avatar automatically whenever a new user is created.
- Prefers Gravatar and falls back to a generated Laravolt image when no Gravatar exists.
- Stores uploaded avatar files through
laravel-enso/files. - Deletes the previously attached file when an avatar is replaced.
- Enforces square image uploads.
- Exposes avatar display, upload, and regenerate endpoints under the core API namespace.
- Registers permissions and authorization for avatar operations.
Usage
The package binds an avatar() relation and generateAvatar() method to the Enso user model:
$user->avatar; $user->generateAvatar();
Store a custom uploaded avatar for the authenticated user:
use Illuminate\Http\UploadedFile; $request->validate([ 'avatar' => 'required|image:allow_svg|dimensions:ratio=1', ]); $request->user()->avatar->store( UploadedFile::fake()->image('avatar.png', 512, 512), );
Regenerate the default avatar:
$request->user()->generateAvatar();
Display an avatar in the browser by hitting the show endpoint:
route('core.avatars.show', $user->avatar->id);
::: warning Note The package is designed to work with a single avatar per user. When you regenerate or upload a new avatar, the previously attached file is removed automatically. :::
API
Routes
All package routes are registered under:
- prefix:
api/core/avatars - name prefix:
core.avatars. - middleware:
api,auth,core
Endpoints:
POST /api/core/avatarsPATCH /api/core/avatars/{avatar}GET /api/core/avatars/{avatar}
Authorization
LaravelEnso\Avatars\Policies\AvatarPolicy
- superiors may manage any avatar
- regular users may update only their own avatar
- impersonating users may not update avatars
Model
LaravelEnso\Avatars\Models\Avatar
Persisted fields:
user_idfile_idurl
Relationships:
user()file()
Useful methods:
store(UploadedFile $uploadedFile)extensions()mimeTypes()imageWidth()imageHeight()
Dynamic User Integration
Dynamic additions on LaravelEnso\Users\Models\User:
avatar()generateAvatar()
Command
Generate missing avatars for users without one:
php artisan enso:avatars:generate
Depends On
Required Enso packages:
laravel-enso/core↗laravel-enso/dynamic-methods↗laravel-enso/files↗laravel-enso/image-transformer↗laravel-enso/migrator↗laravel-enso/users↗
Companion frontend package:
External dependency:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
laravel-enso/avatarmanager 适用场景与选型建议
laravel-enso/avatarmanager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.33k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「avatars」 「avatar」 「laravel-enso」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel-enso/avatarmanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-enso/avatarmanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel-enso/avatarmanager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generate an Adorable Avatar for Laravel
User Avatar manager dependency for Laravel Enso
Change the default avatar url provider with one for inline SVGs
User Avatar manager dependency for Laravel Liberu
Avatar extension for Contao Open Source CMS
This Twig extension generates user avatar using name initials letter inside Twig templates
统计信息
- 总下载量: 16.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-22