Package Data | |
---|---|
Maintainer Username: | tournasdim |
Maintainer Contact: | tournasdimitrios@gmail.com (Tournas Dimitrios) |
Package Create Date: | 2013-07-02 |
Package Last Update: | 2013-12-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:24:06 |
Package Statistics | |
---|---|
Total Downloads: | 271 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 10 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 1 |
An avatar is a graphical representation of a user . It could be the person’s picture , or a random icon they want to be associated with . All a user has to do is to register an account based on their email address and upload an avatar to associate with that account . On the other side of the coin , webmasters that want to let their visitors graphically identify themselves have to implement a REST request to Gravatar's API . The request is just an URL encoded string with the email address of the user . If Gravatar's servers recognize this email address as a registered user , the user's associated Avatar is send back . Webmasters can also configure their system to automatically display an Identicon when a user has no registered Gravatar . This library is meant to be used as a Laravel 4.0 / 4.1 package and help PHP developers be concentrated on more important parts of their Laravel project .
It is assumed that you already have a working Laravel 4 project . Basic knowledge with Laravel's concepts are also required . For instance : Route , Controller , Blade or Authentication-adapter shouldn't be "strange" words to you .
##Installation :
composer.json
file{
"require": {
"laravel/framework": "4.0.*" ,
"tournasdim/laravel4-getgravatar": "dev-master"
}
}
composer update
command from your project's rootapp/config/app.php
:'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `
'Tournasdim\Getgravatar\GetgravatarServiceProvider' ),
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'View' => 'Illuminate\Support\Facades\View',
```` ```` ```` ```` ```` ````
'Gravatar' => 'Tournasdim\Getgravatar\Facades\Getgravatar' ,
php artisan config:publish "tournasdim/laravel4-getgravatar"
and open the file "app/config/packages/tournasdim/getgravatar/config.php" to customize basic functionality (size , customGravUrl , defGrav , authAdapter , maxRating) . Every option is explained in the configuration file , drop me an issue if you need specific help though .##Un-Installing the package :
composer.json
fileapp/config/app.php
app/config/app.php
app/config/packages
directory . Instead of manually removing this directory , alternatively use the CLI : php artisan gravatar:uninstall
composer update
command .defGrav
will be used as parameter (a predefined fallback avatar) ./*
Defining an Email address :
1) If recognized by Gravatar's server , its accompanied image is returned , else
2) An alternative Avatar is returned (randomly chosen from a "pool" )
*/
Route::get('/' , function()
{
return Gravatar::get( null , false , 'johndoe@gmail.com' ) ;
});
/*
* No Email address defined : For logged-in users , their email address will be send to Gravatar's API .
*/
Route::get('/' , function()
{
return Gravatar::get() ;
});
/*
Disable "random image" , which Avatar is returned depends on :
1) if "customGravUrl" is defined , then return the image from that Url
2) if "customGravUrl" was not defined then use the image specified in "defGrav".
*/
Route::get('/' , function()
{
return Gravatar::get(null , false) ;
});
// Defining an Avatar from a Route and passing it to the View
Route::get('/' , function()
{
$gravatar = \Gravatar::get() ;
return View::make('welcome')->with('gravatar' , $gravatar) ;
});
<?php namespace Tournasdim\Admin\Controllers ;
class AdminController extends BaseController {
// No Email specified , Auth's adapter Interface will try to resolve user's Email address .
public function showWelcome()
{
$gravatar = \Gravatar::get() ;
return View::make('admin.dashboard')
->with('gravatar' , $gravatar) ;
}
}
?>
// admin/dashboard.blade.php
@extends('layouts.admin'))
@section('header')
<h3>
<i class="icon-dashboard"></i>
Dashboard {{$gravatar}}
</h3>
@stop
<?php namespace Tournasdim\Admin\Controllers ;
class AdminController extends BaseController {
// Email is specified , this will be used into the query-string
public function showWelcome()
{
$gravatar = \Gravatar::get(null , false , 'johndoe@gmail.com') ;
return View::make('admin.dashboard')
->with('gravatar' , $gravatar) ;
}
}
?>
// admin/dashboard.blade.php
@extends('layouts.admin'))
@section('header')
<h3>
<i class="icon-dashboard"></i>
Dashboard {{$gravatar}}
</h3>
@stop
<?php namespace Tournasdim\Admin\Controllers ;
class BaseController extends Controller {
protected $gravatar ;
public function __construct()
{
$this->gravatar = \Gravatar::get() ;
}
?>
// A controller that extends the base controller
<?php namespace Tournasdim\Admin\Controllers ;
class AdminController extends BaseController {
public function index()
{
return View::make('admin.dashboard')
->with('gravatar' , $this->gravatar);
}
public function profiler()
{
return View::make('admin.profiler')
->with('gravatar' , $this->gravatar);
}
}
?>
// views/admin/dashboard.blade.php
@extends('layouts.admin'))
@section('header')
<h3>
<i class="icon-dashboard"></i>
Dashboard {{$gravatar}}
</h3>
@stop
Open a new issue on this repository and I'll try to help . Please limit your question(s) only to issues related to this project . Laravel's forums / IRC are more suited places to get general information about the Framework . Reports about bugs are welcome , but also , I would be glad to hear about your experience and suggestions of this repository .
Of course the creator of the Laravel Framework (Taylor Otwell) and all active members of Laravel's forum / IRC channel .
Getgravatar
@copyright Tournas Dimitiros 2013
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
@author Tournas Dimitrios tournasdimitrios@gmail.com @version V1.0.0