thomaswelton/laravel-gravatar
最新稳定版本:1.3.0
Composer 安装命令:
composer require thomaswelton/laravel-gravatar
包简介
Laravel 5 Gravatar helper
README 文档
README
Installation
Update your composer.json file to include this package as a dependency
"thomaswelton/laravel-gravatar": "~1.0"
This package supports the package discovery functionality provided in Laravel 5.5, so registering the classes as described below is no longer necessary if you use Laravel 5.5.
Register the Gravatar service provider by adding it to the providers array in the config/app.php file.
Thomaswelton\LaravelGravatar\LaravelGravatarServiceProvider::class
Alias the Gravatar facade by adding it to the aliases array in the config/app.php file.
'aliases' => [ 'Gravatar' => Thomaswelton\LaravelGravatar\Facades\Gravatar::class ]
Configuration - Optional
Copy the config file into your project by running
php artisan vendor:publish --provider="Thomaswelton\LaravelGravatar\LaravelGravatarServiceProvider"
Default Image
Update the config file to specify the default avatar size to use and a default image to be return if no Gravatar is found.
Allowed defaults:
- (string)
<custom URL>: the URL to an image of your choice (publicly available, with an image extension and without a query string). - (string)
404: do not load any image if none is associated with the email hash, instead return an HTTP 404. - (string)
mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash). - (string)
identicon: a geometric pattern based on an email hash. - (string)
monsterid: a generated 'monster' with different colors, faces, etc. - (string)
wavatar: generated faces with differing features and backgrounds. - (string)
retro: awesome generated, 8-bit arcade-style pixelated faces.
Example images can be viewed on the Gravatar website.
Content Ratings
By default only "G" rated images will be shown. You can change this system wide in the config file by editing 'maxRating' => 'g' allowed values are
g: suitable for display on all websites with any audience type.pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.x: may contain hardcore sexual imagery or extremely disturbing violence.
The content rating can be changed by changing the $rating argument when calling Gravatar::src or Gravatar::image.
Usage
Gravatar::exists($email)
Returns a boolean telling if the given $email has got a Gravatar.
Gravatar::src($email, $size = null, $rating = null)
Returns the https URL for the Gravatar of the email address specified. Can optionally pass in the size required as an integer. The size will be contained within a range between 1 - 512 as gravatar will no return sizes greater than 512 of less than 1
<!-- Show image with default dimensions --> <img src="{{ Gravatar::src('thomaswelton@me.com') }}"> <!-- Show image at 200px --> <img src="{{ Gravatar::src('thomaswelton@me.com', 200) }}"> <!-- Show image at 512px scaled in HTML to 1024px --> <img src="{{ Gravatar::src('thomaswelton@me.com', 1024) }}" width=1024>
Gravatar::image($email, $alt = null, $attributes = [], $rating = null)
Returns the HTML for an <img> tag
// Show image with default dimensions echo Gravatar::image('thomaswelton@me.com'); // Show image at 200px echo Gravatar::image('thomaswelton@me.com', 'Some picture', ['width' => 200, 'height' => 200]); // Show image at 512px scaled in HTML to 1024px echo Gravatar::image('thomaswelton@me.com', 'Some picture', ['width' => 1024, 'height' => 1024]);
thomaswelton/laravel-gravatar 适用场景与选型建议
thomaswelton/laravel-gravatar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06M 次下载、GitHub Stars 达 290, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「gravatar」 「laravel」 「laravel5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thomaswelton/laravel-gravatar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thomaswelton/laravel-gravatar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thomaswelton/laravel-gravatar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A library providing easy gravatar integration/generation (Laravel supported).
Library to validate and parse social media profile URLs
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Laravel helpers for dev
Send SMS and SMS Notification via Mailjet for Laravel
Gravatar creator for Nette Framework
统计信息
- 总下载量: 1.06M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 306
- 点击次数: 11
- 依赖项目数: 19
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 未知