PHPackages                             artdarek/avatarer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. artdarek/avatarer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

artdarek/avatarer
=================

Avatarer - Social media avatars for Laravel 5

2.0.2(9y ago)1015.4k1MITPHPPHP &gt;=5.3.0

Since Sep 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/artdarek/avatarer)[ Packagist](https://packagist.org/packages/artdarek/avatarer)[ Docs](https://github.com/artdarek/avatarer)[ RSS](/packages/artdarek-avatarer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Avatarer - Social media avatars for Laravel 5
=============================================

[](#avatarer---social-media-avatars-for-laravel-5)

Easy get avatars from social services like Facebook.com and Gravatar.com

- initially package was build for Laravel 5 but it can work as standalone library too.

---

- [Supported Providers](#supported-providers)
- [Installation](#installation)
- [Registering the Package](#registering-the-package)
- [Usage](#usage)
- [Output Formating](#output-formating)

Supported Providers
-------------------

[](#supported-providers)

A Provider can be a social network service that allows to get it's users avatars. As for right now we support:

- Gravatar
- Facebook
- Twitter

Installation
------------

[](#installation)

#### Via composer require command

[](#via-composer-require-command)

Use [composer](http://getcomposer.org) require command to install this package.

```
$ composer require artdarek/avatarer
```

#### Adding package to composer.json file manually

[](#adding-package-to-composerjson-file-manually)

Add package to your composer.json file:

```
"require": {
  "artdarek/avatarer": "2.0.*"
}

```

Use [composer](http://getcomposer.org) update command to install this package.

```
$ composer update
```

### Registering the Package

[](#registering-the-package)

Add the Avatarer alias into your config file `config/app.php`:

```
'aliases' => [
    'Avatarer' => Artdarek\Avatarer\Support\Laravel\Facades\Avatarer::class,
],
```

Usage
-----

[](#usage)

#### Initialize

[](#initialize)

To ininitialize Avatarer call make() method and pass Provider name (service name like Gravatar/Facebook/Twitter):

```

```

```

```

```

```

If you want to use Avatarer library outside of Laravel framework or you don't want to use `Avatarer Facade` in your Laravel application, you can do this:

```

```

or

```

```

or

```

```

#### Setting a user

[](#setting-a-user)

Generating avatar with default settings is very simple and all you have to do is to call `user()` method with user id as a parameter (each Provider can identify user differently via email/id/screenname etc.):

For Gravatar we use Email:

```

```

For Facebook we use UserID:

```

```

For Twitter we use user ScreenName:

```

```

#### Setting avatar size

[](#setting-avatar-size)

If you want to set a size of avatar that should be returned you can use `size()` method. This method can take two parameters `width` and `height` and both are optional (notice that not all providers will require or use both width and height, for example Gravatar expects only width).

For Gravatar:

```

```

For Facebook:

```

```

#### Setting provider-specific options

[](#setting-provider-specific-options)

If you want to customize avatar a little bit more you can set some additional parameters using `options()` method.

For Gravatar:

```

```

For Facebook:

```

```

#### Methods chaining

[](#methods-chaining)

If thats more convinient for you you can chain all methods like below:

```
