Code Monkey home page Code Monkey logo

gravatari's Introduction

gravatari

A simple gravatar package for php

  • Provides a fluent interface with Gravatar API
  • Seamless integration with Laravel 4

Installation

Installing via Composer

The recommended way to install Gravatari is through Composer.

  1. Add malonmedia/gravatari as a dependency in your project's composer.json file:

     {
         "require": {
             "malonmedia/gravatari": "*"
         }
     }
    
  2. Download and install Composer:

     curl -s http://getcomposer.org/installer | php
    
  3. Install your dependencies:

     php composer.phar install
    
  4. Require Composer's autoloader

    Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process:

     require 'vendor/autoload.php';
    

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.

Usage

Images (avatars)

<?php

use Gravatari\Api\Image;

$gravatar = new Image;

// Generate url for 80x80 avatar using Mystery Man if avatar does not exist
$url = $gravatar->size(80)->default('mm')->url('[email protected]');

Options

size(80)                size in pixels                      1 - 2048
default('404')          image to use as default             404, mm, identicon, monsterid, wavatar, retro, blank, OR an url
forceDefault('no')      whether to force default image      yes, no
rating('g')             maximum allowed content rating      g, pg, r, x

Url Generation

    url('[email protected]')          //retrieve the url for the supplied email's gravatar
    
    urlSecure('[email protected]')    //retrieve a secure url for the supplied email's gravatar

Profiles

<?php

use Gravatari\Api\Profile;

$profile = new Profile;

// Url Methods (retrieve url in specified format)
$profile->url('[email protected]');
$profile->urlJson('[email protected]');
$profile->urlJson('[email protected]', 'alert');      //Json method accepts optional javascript callback paremeter
$profile->urlXml('[email protected]');
$profile->urlPhp('[email protected]');
$profile->urlVcf('[email protected]');
$profile->urlQr('[email protected]');

// Request Methods (send request and return response for specified format)
$profile->requestJson('[email protected]');
$profile->requestJson('[email protected]', 'alert');  //Json method accepts optional javascript callback paremeter
$profile->requestXml('[email protected]');
$profile->requestPhp('[email protected]');

Extensions

Support for some common frameworks is/will be provided through extensions. Below are instructions for currently supported extensions (more will be provided in the future):

Laravel 4

  1. Add 'Gravatari\Extension\Laravel\GravatariServiceProvider', to the providers array in app/config/app.php.
  2. Add 'Gravatari' => 'Gravatari\Extension\Laravel\Facades\Gravatari', to the aliases array in app/config/app.php.
  3. To access the avatar api, use Gravatari::image()->url('[email protected]') or simply Gravatari::url('[email protected]')
  4. To access the profile api, use Gravatari::profile()->urlJson('[email protected]')

gravatari's People

Contributors

jwalton512 avatar jbirchmore avatar jchaney01 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.