2017 © Pedro Peláez
 

library silex-gravatar

Gravatar extension for Silex

image

mheap/silex-gravatar

Gravatar extension for Silex

  • Tuesday, October 10, 2017
  • by mheap
  • Repository
  • 2 Watchers
  • 6 Stars
  • 2,980 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Silex-Markdown

Build Status, (*1)

Requirements

This extension only works with PHP 7.1+ and Silex 2. Version 1.1.0 is compatible with Silex 1., (*2)

Installation

Install with composer:, (*3)

composer require mheap/silex-gravatar

Usage

First, you need to register the Gravatar extension. All of the options shown are optional., (*4)

$app->register(new SilexExtension\GravatarExtension(), array(
    'gravatar.cache_dir'  => sys_get_temp_dir() . '/gravatar',
    'gravatar.cache_ttl'  => 240, // 240 seconds
    'gravatar.options' => array(
        'size' => 100,
        'rating' => Gravatar\Service::RATING_G,
        'secure' => true,
        'default'   => Gravatar\Service::DEFAULT_404,
        'force_default' => true
    )
));

To fetch a Gravatar URL, use $app['gravatar']:, (*5)

$app->get('/', function() use($app) {
    return $app['gravatar']->get('m@michaelheap.com');
});

If you're using Twig via Silex\Provider\TwigServiceProvider(), a gravatar function will be automatically registered for you. This allows you do do the following:, (*6)

{% if gravatar_exist('m@michaelheap.com') %}
    Gravatar found
{% endif %}

<img src="{{ gravatar('m@michaelheap.com', {'size': 50}) }}" />

Available configuration options

The GravatarExtension provides access to the Gravatar web service through Sven Eisenschmidts's Gravatar <https://github.com/fate/Gravatar-php>_ library., (*7)

  • gravatar.cache_dir (optional): A directory to cache the direct web service calls to gravatar.com
  • gravatar.cache_ttl (optional): The time how long a cache entry will live, defaults to 360 seconds
  • gravatar.options (optional): An associative array of arguments for the Gravatar\Service class

Running the tests

There are no external dependencies for this library. Just composer install then run ./vendor/bin/phpunit, (*8)

The Versions

10/10 2017

dev-master

9999999-dev https://github.com/mheap/Silex-Gravatar

Gravatar extension for Silex

  Sources   Download

MIT

The Requires

 

The Development Requires

silex avatar gravatar

10/10 2017

dev-silex-2-php-7

dev-silex-2-php-7 https://github.com/mheap/Silex-Gravatar

Gravatar extension for Silex

  Sources   Download

MIT

The Requires

 

The Development Requires

silex avatar gravatar