Download the PHP package forxer/gravatar without Composer

On this page you can find all versions of the php package forxer/gravatar. 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

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

Index

Installation

Requirements

If you want to use it with a version earlier than PHP 8.2, please use one of the previous versions that suits your needs: v4, v3, v2 or v1.

With Composer

The easiest way to install Gravatar is via Composer. Run the following command in the root of your project:

Without Composer

You should use composer, it's so convenient. However, if you really do not want, or can not, you can download the latest version and unpack the archive.

Then, you do what it takes to use it with your own autoloader. The examples below use the Composer autoloader.

Back to top ^

Usage

There are many ways to use this library:

All of these ways return instances of Gravatar\Image and Gravatar\Profile that allow you to define specific settings/parameters as needed.

Whatever method you use, you could use the url() method to retrieve it. Or display the URL directly because they implement the __toString() method.

Use helpers

The easiest way to use this library is to use the helper functions.

Since version 4, in order to avoid conflicts with other packages, we no longer define the gravatar() and gravatar_profile() helpers. It's up to you to do this in your app with names that work for you and don't conflict with others. Here's how to do it; it's simple.

In a file dedicated to the helper functions, define the version 3 functions using the names that suit you.

If you do not have a helpers functions file, you can create one for example at the root of your project, which you name helpers.php and which you fill in the composer.json file so that it is autoloaded. For example :

This way you can use them like this:

Back to top ^

Use the Gravatar base class

But it is also possible to use the static methods of the base Gravatar class.

Single Gravatar image/profile

If you want to retrieve a single Gravatar image/profile URL you can use the main Gravatar class like this:

Back to top ^

Multiples Gravatar images/profiles

If you want to retrieve multiples Gravatar images/profiles URL you can also use the main Gravatar class with Gravatar::images() and Gravatar::profiles() methods.

Note the presence of the "s" character at the end of methods names.

The Gravatar::images() and Gravatar::profiles() methods return an array of instances of Gravatar\Image and Gravatar\Profile.

Back to top ^

Instanciate the dedicated classes

In fact, either gravatar() and gravatar_profile() helpers functions or Gravatar::image(), Gravatar::images(), Gravatar::profile() and Gravatar::profiles() static methods are just shortcuts for convenient use.

Behind these helpers functions and static methods, there are two classes : Gravatar\Image and Gravatar\Profile.

In some case, for some reason, you would use the library in another way. For exemple with a dependency injection container.

Back to top ^

Mandatory parameter

Obviously the email address is a mandatory parameter that can be entered in different ways.

These previous examples are also valid for the profile.

Back to top ^

Optional parameters

Gravatar image size

By default, images are presented at 80px by 80px if no size parameter is supplied. You may request a specific image size, which will be dynamically delivered from Gravatar. You may request images anywhere from 1px up to 2048px, however note that many users have lower resolution images, so requesting larger sizes may result in pixelation/low-quality images.

An avatar size should be an integer representing the size in pixels.

If you want to retrieve the currently set avatar size, you can use one of following methods:

Back to top ^

Default Gravatar image

What happens when an email address has no matching Gravatar image or when the gravatar specified exceeds your maximum allowed content rating?

By default, this:

Default Gravatar image

If you'd prefer to use your own default image, then you can easily do so by supplying the URL to an image. In addition to allowing you to use your own image, Gravatar has a number of built in options which you can also use as defaults. Most of these work by taking the requested email hash and using it to generate a themed image that is unique to that email address. To use these options, just pass one of the following keywords:

Mystery-man default Gravatar image Identicon default Gravatar image Wavatar default Gravatar image Retro default Gravatar image Robohash default Gravatar image Blank default Gravatar image

If you want to retrieve the currently set avatar default image, you can use one of following methods:

Back to top ^

Gravatar image max rating

Gravatar allows users to self-rate their images so that they can indicate if an image is appropriate for a certain audience. By default, only 'g' rated images are displayed unless you indicate that you would like to see higher ratings.

You may specify one of the following ratings to request images up to and including that rating:

If you want to retrieve the currently set avatar max rating, you can use one of following methods:

Back to top ^

Gravatar image file-type extension

If you require a file-type extension (some places do) then you may also specify it.

You can specify one of the following extensions for the generated URL:

If you want to retrieve the currently set avatar file-type extension, you can use one of following methods:

Back to top ^

Force to always use the default image

If for some reason you wanted to force the default image to always be load, you can do it:

To check to see if you are forcing default image, call the method forcingDefault() of Gravatar\Image, which will return a boolean value regarding whether or not forcing default is enabled.

Back to top ^

Gravatar profile format

Gravatar profile data may be requested in different data formats for simpler programmatic access.

The following formats are supported:

Back to top ^

License

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


All versions of gravatar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
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 forxer/gravatar contains the following files

Loading the files please wait ....