承接 forxer/gravatar 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

forxer/gravatar

最新稳定版本:6.0.0

Composer 安装命令:

composer require forxer/gravatar

包简介

A library providing easy gravatar integration.

README 文档

README

Latest Stable Version Total Downloads License

Gravatar

Gravatar is a small library intended to provide easy integration of... Gravatar :) It will help you generate the URL for Gravatar images and profiles in many ways.

To use it in a Laravel project, please look at: laravel-gravatar

use Gravatar\Gravatar;
use Gravatar\Enum\DefaultImage;
use Gravatar\Enum\Extension;

$avatar = Gravatar::image('email@example.com')
    ->size(120)
    ->defaultImage(DefaultImage::ROBOHASH)
    ->extension(Extension::JPG);
//...
echo $avatar;

Documentation

Quick Start

Installation

composer require forxer/gravatar

Requires PHP 8.4 or newer. For older PHP versions, see Installation.

Basic Usage

use Gravatar\Gravatar;

// Get a Gravatar image URL
echo Gravatar::image('email@example.com');
// output: //www.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e

// With parameters
$avatar = Gravatar::image('email@example.com')
    ->size(120)
    ->ratingPg()
    ->extensionWebp()
    ->defaultImageRobohash();
echo $avatar;

// Get a Gravatar profile URL
echo Gravatar::profile('email@example.com')->formatJson();

Key Features

Type-safe enums for better IDE support:

use Gravatar\Enum\Rating;
use Gravatar\Enum\Extension;
use Gravatar\Enum\DefaultImage;

$image->setMaxRating(Rating::PG)
    ->setExtension(Extension::WEBP)
    ->setDefaultImage(DefaultImage::ROBOHASH);

Fluent shorthand methods for cleaner syntax:

$image->ratingPg()
    ->extensionWebp()
    ->defaultImageRobohash();

Multiple usage patterns - helpers, static methods, or direct instantiation:

// Using helpers (define your own)
$avatar = gravatar('email@example.com')->size(120);

// Using static methods
$avatar = Gravatar::image('email@example.com')->size(120);

// Direct instantiation
$avatar = new Image('email@example.com');
$avatar->size(120);

For more details, see the full documentation.

License

This library is licensed under the MIT license; you can find a full copy of the license itself in the file /LICENSE

统计信息

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

GitHub 信息

  • Stars: 29
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-19