This package is abandoned and no longer maintained. No replacement package was suggested.

3.2.0 2019-08-28 13:05 UTC

This package is auto-updated.

Last update: 2020-01-28 14:19:48 UTC


Build Status PHP from Packagist Latest Version License


Require this package, with Composer, in the root directory of your project.

$ composer require artisanry/sociable


To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish --provider="Artisanry\Sociable\SociableServiceProvider"

And then run the migrations to setup the database table.

$ php artisan migrate


Setup a Model
namespace App;

use Artisanry\Sociable\Sociable;
use Illuminate\Database\Eloquent\Model;

class User extends Model
    use Sociable;
Authenticating a User
use Artisanry\Sociable\Services\Authenticator;
use Artisanry\Sociable\Events\UserHasSocialized;

$router->get('/', function (Authenticator $authenticate, Request $request) {
    return $authenticate->provider('github') // authenticate with github
                        ->model(User::class) // this can also be a model like User::find(1) if you want to attach multiple social profiles to one model
                        ->mapField('username', 'nickname') // map the nickname field to the username column on the user model
                        ->mapField('email', 'email') // map the email field to the email column on the user model
                        ->mapField('avatar', 'avatar') // map the avatar field to the avatar column on the user model
                        ->mapField('password', bcrypt(str_random(10)), true) // add an additional password field to the user model
                        ->event(UserHasSocialized::class) // this event will be fired after the user profile has been retrieved
                        ->execute($request->has('code')); // if no code is available we will redirect instead of processing the response
Default Event

The default event that is fired is UserHasSocialized which will take care of creating and updating all models.

Custom Event

If you need to have your own way of handling the response take a look at UserHasSocialized and UserHasSocializedListener and create your event and listener.

Once you've done that you can just use ->event(MyCustomEvent::class) and the response will be passed through to your event.


$ phpunit


If you discover a security vulnerability within this package, please send an e-mail to All security vulnerabilities will be promptly addressed.


This project exists thanks to all the people who contribute.


Mozilla Public License Version 2.0 (MPL-2.0).