定制 forxer/laravel-gravatar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

forxer/laravel-gravatar

最新稳定版本:5.0.0

Composer 安装命令:

composer require forxer/laravel-gravatar

包简介

A library providing easy gravatar integration in a Laravel project.

README 文档

README

Latest Stable Version Total Downloads License

Gravatar for Laravel

This package provides an easy Gravatar integration in a Laravel project.

use Gravatar\Enum\DefaultImage; use Gravatar\Enum\Extension; // Simple usage $avatar = gravatar('email@example.com') ->size(120) ->defaultImage('robohash') ->extension('jpg'); echo $avatar; // With type-safe enums $avatar = gravatar('email@example.com') ->size(120) ->defaultImage(DefaultImage::ROBOHASH) ->extension(Extension::JPG); // With fluent shorthand methods $avatar = gravatar('email@example.com') ->size(120) ->extensionJpg() ->defaultImageRobohash();

About this package

This Laravel package is built on top of the framework-agnostic forxer/gravatar library. It extends the base functionality by adding:

  • Laravel-specific features: Service providers, facades, helper functions (gravatar() and gravatar_profile()), and configuration
  • Extended classes: LaravelGravatar\Image extends Gravatar\Image, and LaravelGravatar\Profile extends Gravatar\Profile
  • Additional Laravel integrations: Eloquent casts, preset configurations, and base64 conversion with Laravel's HTTP client
  • Full support for PHP 8.4 features: Property hooks, type-safe enums, and fluent shorthand methods from the parent library

All the core Gravatar functionality from the parent library is available in this package.

Documentation

Complete documentation is available in the docs directory:

Requirements

  • PHP 8.4+
  • Laravel 12.0+

For earlier versions:

Quick Installation

composer require forxer/laravel-gravatar

The service provider is automatically registered via package discovery.

Quick Start

// Simple usage with helper <img src="{{ gravatar($user->email) }}" alt="Avatar"> // With configuration $avatar = gravatar('user@example.com') ->size(120) ->extensionWebp() ->defaultImageRobohash(); // Using presets $avatar = gravatar($user->email, 'small'); // With Eloquent casts class User extends Model { protected $casts = [ 'email' => GravatarImage::class.':medium', ]; } // In Blade <img src="{{ $user->email }}" alt="Avatar">

Key Features

  • Helper functions - gravatar() and gravatar_profile() for quick access
  • Facade support - Gravatar::image() and Gravatar::profile()
  • Eloquent casts - Seamless model integration
  • Preset configurations - Define reusable avatar settings with automatic validation
  • Enum-based validation - Preset values validated against type-safe enums at runtime
  • Base64 conversion - Convert avatars to data URLs
  • PHP 8.4 property hooks - Direct property access with validation
  • Type-safe enums - Rating, Extension, DefaultImage, ProfileFormat
  • Fluent shorthand methods - extensionWebp(), ratingPg(), defaultImageRobohash()

Version History

See CHANGELOG.md for all changes.

Upgrading

See UPGRADE.md for upgrade instructions between major versions.

License

This package is open-source software licensed under the MIT license.

统计信息

  • 总下载量: 32.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 44
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 42
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固