承接 artlabs/gravatar 相关项目开发

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

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

artlabs/gravatar

Composer 安装命令:

composer require artlabs/gravatar

包简介

Avatar Generator

README 文档

README

Installation

Add Gravatar to your composer.json file:

composer require artlabs/gravatar

Use composer to install this package.

$ composer update

Registering the Package

Add the Gravatar Service Provider to your config in config/app.php:

'providers' => array(
	Artlabs\Gravatar\GravatarServiceProvider::class
),

Usage

Generating gravatar url by user() method

Generating avatar with default settings is very simple and all you have to do is to call user() method with user email as a paramterer:

<?php
	// user email
	$email = "example@user.email";

	// create a gravatar object for specified email
 	$gravatar = Gravatar::user( $email );

	 // get gravatar url as a string
	$url = $gravatar->url();

?>

If you want to customize avatar a little bit you can set some more parameters using additional methods like size(), rating(), defaultImage().

<?php
	// user email
	$email = "example@user.email";

	// create a gravatar object for specified email with additional settings
 	$gravatar = Gravatar::user( $email );

 	// Size in pixels, defaults to 80px [ 1 - 2048 ]
	$gravatar->size('220');

	// Maximum rating (inclusive) [ g | pg | r | x ]
	// defaults to 'g'
	$gravatar->rating('g');

	// Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
	// You can also specify url to your own default avatar image
	// defaults to 'mm'
	$gravatar->defaultImage('mm');

    // set Gravatar to build urls with https [true = use https, false = ise http]
    // defaults to 'false'
    $gravatar->secured( true );

	// get gravatar url as a string
	$url = $gravatar->url();

?>

U can also chain all methods:

<?php
 	$url = Gravatar::user( $email )->size('220')->rating('g')->defaultImage('mm')->url();
?>

Generating gravatar url by make() method

Basic way to generate gravatar url is just to call make() method with user email address as a parameter (all other parameters will be loaded from defaults).

<?php
	// user email
	$email = "example@user.email";

	// create a gravatar object for specified email
 	$gravatar = Gravatar::make( $email );

	 // get gravatar url as a string
	$url = $gravatar->url();

?>

U can aslo chain methods:

<?php
	// to get url string
	$url = Gravatar::make( $email )->url();
?>

If you want specify size of avatar or some other additional parameters you can do this by passing array with parameters to make() method:

<?php
	// user email
	$email = "example@user.email";

	// create a gravatar object in specified size
 	$url = Gravatar::make( ['email' => $email, 'size' => 220] )->url();

	// create a gravatar object with some other additional parameters
 	$url = Gravatar::make( [
 		'email' => $email,
 		'size' => 220,
 		'defaultImage' => 'mm',
 		'rating' => 'g',
 	    'secured' => true
 	])->url();
?>

Generating HTM avatar code

With Gravatar you can get url string of user avatar by calling url() method but also you can generate full html code by calling html() method instead of url().

<?php
	// user email
	$email = "example@user.email";

	// create some Gravatar object
 	$gravatar = Gravatar::user( $email )->size('120');

	 // get gravatar <img> html code
	$html = $gravatar->html();
?>

If you want to have more controll over the returned html code you can pass some additional html attributes to html() method, for examle:

<?php
	$html = Gravatar::user( $email )->html( ['class' => 'avatar', 'id' => 'user123' ] );
?>

artlabs/gravatar 适用场景与选型建议

artlabs/gravatar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 artlabs/gravatar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 artlabs/gravatar 我们能提供哪些服务?
定制开发 / 二次开发

基于 artlabs/gravatar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-06