Download the PHP package rackbeat/laravel-ui-avatars without Composer

On this page you can find all versions of the php package rackbeat/laravel-ui-avatars. 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-ui-avatars

Official Laravel wrapper for https://ui-avatars.com

Build Status Coverage Total Downloads Latest Stable Version License

Installation

You just require using composer and you're good to go!

The Service Provider is automatically registered.

Setup

To setup the config file, you publish it like so:

You can edit the file in config/ui-avatars.php.

Usage

1. Add the Rackbeat\UIAvatars\HasAvatar trait to your Model (e.g. App\Users)

2. Create a new method on your Model.

This method is practically a proxy to call the HasAvatar methods. It will return a gravatar from the e-mail, with a fallback to the avatar using ui-avatars.com API.

NOTICE: Gravatar is only available using the API, not locally generated avatars.

3. (Optional) Re-define the name field

Assuming you're not using the default User Model in Laravel, you can override which field is being used for the name.

Available methods

getInitials($length=null)

Returns the generated initials, from the name, used in the avatar.

Default $length can be defined in config/ui-avatars.php (length key)

getUrlfriendlyAvatar($size=null)

Return a urlfriendly formatted avatar (URL or base64).

Example usage:

Default $size can be defined in config/ui-avatars.php (image_size key)

getAvatarBase64($size=null)

Return a base64 representation of the avatar.

Default $size can be defined in config/ui-avatars.php (image_size key)

getAvatarImage($size=null)

Return a Image object of the avatar.

Default $size can be defined in config/ui-avatars.php (image_size key)

getGravatar($email, $size=null)

Return a link to a Gravatar image using the specified email, and a fallback to using our own generator (assuming provider = api)

Default $size can be defined in config/ui-avatars.php (image_size key)

Available options

In the config file you can specify different options.

Key Description Default Available Options / Type
provider Which provider to use for generating avatars. api local or api
length Max initials length (amount of letters) 2 Number, min: 1, max: unlimited
image_size Default width & height for the generated avatar. 48 Number, min: 1, max: unlimited (512 using api provider)
font_size Font size in percentage of image_size. 0.5 Number, min: 0, max: 1
rounded Should the generated avatar be a rounded circle? (its recommended to disable and round using CSS) false Boolean
smooth_rounding If rounded is enabled, and provider is local, you can enable smoother rounding with the cost of performance. true Boolean
uppercase Should the initials be forced uppercase or not. true Boolean
background_color Default HEX background color for avatars. #a0a0a0 Hex
font_color Default HEX font color for avatars. #222 Hex
providers List of available providers. For you to add your own provider. Array of providers

Requirements


All versions of laravel-ui-avatars with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
lasserafn/php-initial-avatar-generator Version ^4.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.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 rackbeat/laravel-ui-avatars contains the following files

Loading the files please wait ....