Download the PHP package nicolas-gille/gravatar-lib without Composer

On this page you can find all versions of the php package nicolas-gille/gravatar-lib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gravatar-lib

Gravatar Lib

Gravatar Lib is a small library to help integration of the gravatar service on your app.

Requirements

Usage

Installation

You can install Gravatar Lib with composer to execute the following command : $ composer require nicolas-gille/gravatar-lib Yan can clone or download the source directly from Github, and install it on your app.

General example

Settings the size of the avatar.

Gravatar offer to change the size of your avatar. By default, the value provide by Gravatar is 80 pixels, but, you can extends it at 2048 pixels. To update the size of your avatar, use the method GravatarLib\Gravatar\Gravatar->setSize(int).

You can get an example of set size of the avatar below:

Nota Bene :
If you exceed the maximum or the minimum values, this method throw on \InvalidArgumentException with the message The size must be within 0 and 2048.

Settings the default image.

Gravatar provides several default avatar for people who don't have post their avatar. Then, you can change the default image with these method GravatarLib\Gravatar\Gravatar->setDefaultImage(string). The default value offer by Gravatar are : '404', 'mm', 'identicon', 'monsterid', 'retro', 'wavatar' and 'blank'.

Another way to set the default image is to send on correct uri on parameter of the method to get the image instead the default value offer by Gravatar.

To use you own avatar, you can leave the constructor without set the default value to use your avatar.

You can get an example of set default image below:

Nota Bene :
If you send on invalid url or a string not contains in Gravatar API, this method throw on \InvalidArgumentException with the message The default image specified is not a valid URL or present as default value in Gravatar..

Settings the rating image

With Gravatar, you can block certain type of content like ESRB for USA or PEGI for Europe. Then, if you block specific avatar, you can set the max rating allow in your app with the method GravatarLib\Gravatar\Gravatar->setMaxRating(string). The default value allowed in the method are : 'g', 'pg', 'r', 'x'.

You can get an example of set the rating max below:

Nota Bene :
If you send a string different to the valid value, this method throw on \InvalidArgumentException with the message The rating specified is invalid. Use only "g", "pg", "r" or "x" value..

Settings secure uri.

In fact, Gravatar offer two way to get the image respectively in HTTP and in HTTPS. By default, the library load the image via HTTP, but if you would, you can change this method by the method GravatarLib\Gravatar\Gravatar->setSecureUri(bool).

Force default image

You can force the default image for every people who connect on your app with your email. To force the default image, you can use the method GravatarLib\Gravatar\Gravatar->setForceDefaultImage(bool).

Twig integration

You can easily hook this library on you project build with Twig. In fact, to hook the library, you use a Twig_Environment object, and add it on it as a global attribute.

Then, to use it on your template, you must call the object gravatar with the method gravatar.uri(email) to display the avatar.

In the example above, app.user.username and app.user.email contains respectively the username and the mail of the user.

License

This project is under MIT License.

Author


All versions of gravatar-lib with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nicolas-gille/gravatar-lib contains the following files

Loading the files please wait ....