Download the PHP package forxer/laravel-gravatar without Composer

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

Latest Stable Version Total Downloads License

Gravatar for Laravel

This package provides an easy Gravatar integration in a Laravel project.

This package is built on top of forxer/Gravatar. If you want to dig deeper, you can find additional information on its README file.

Index

Requirements

If you want to use it with a version earlier than PHP 8 and/or a version earlier than Laravel 8, please use version 1.

Installation

Install through composer:

Usage

There are three ways to use this library:

All of these ways return an instance of the LaravelGravatar\Gravatar service. The Gravatar service has 3 main methods :

This instances of LaravelGravatar\Image and LaravelGravatar\Profile allow you to define specific settings/parameters as needed. So you can use them to build Gravatar images/profiles URL.

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

Retrieve instances

With the helper

Or with the facade:

Or with the service injection:

Show directly in your views

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

In all the examples below we will use the helper but it obviously works with the facade or the dependency injection of the service.

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.

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

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:

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:

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 LaravelGravatar\Image, which will return a boolean value regarding whether or not forcing default is enabled.

Back to top ^

Combine them

You can combine them seamlessly:

Back to top ^

Image presets

It is possible to define groups of defaults parameters, known as presets. This is helpful if you have standard settings that you use throughout your application. In the configuration file, you can define as many gravatar presets as you wish and a default preset to be used.

First, publish the config file of the package using artisan:

And define some presets in the configuration file in the 'presets' array. There are a few predefined presets for the example in the configuration file, but you are of course free to delete them and define ones that suit your needs. For example:

In the configuration file, for the values key name, as these are array keys and we follow naming conventions, you can use either:

If you wish you can default to one of these presets at the top of the configuration file.

Then, use it in your application with the second argument:

Or you can set it later after instantiation:

Back to top ^

Casts

Let's imagine that your user model has a column "gravatar" which represents the email to use. You can cast this attribute to directly obtain an instance of LaravelGravatar\Image:

Thus it is easy to access the instance and manipulate it:

You can even define a preset name to be used when casting by appending it's name to the cast:

You can also cast to an instance of LaravelGravatar\Profile:

Back to top ^


All versions of laravel-gravatar with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.0
illuminate/support Version ^8.0 || ^9.0 || ^10.0
forxer/gravatar Version ^4.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 forxer/laravel-gravatar contains the following files

Loading the files please wait ....