Skip to content
[Social login]Socialite is an OAuth1/OAuth2 Authentication tool.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

Socialite

Build Status MIT License

Introduction

This is inspired by laravel/socialite, you can easily use it without Laravel.

It possible to use it with various frameworks and middleware.

It is compatible with laravel/socialite.
You can check the Document of laravel.

Core Providers

  • twitter
  • github
  • google
  • facebook
  • bitbucket
  • linkedin

other Providers

Requirement

PHP >= 7.0

Installation

composer require socialite-manager/socialite

Basic Usage

$config = [
    'client_id' => 'xxx',
    'client_secret' => 'xxx',
    'redirect' => 'http://example.com/callback.php',
];

oath.php

use Socialite\Socialite;

Socialite::driver('twitter', $config)->redirect();

callback.php

use Socialite\Socialite;

$user = Socialite::driver('twitter', $config)->user();

$user->getAvatar();
$user->getEmail();
$user->getId();
$user->getNickname();
$user->getName();

Advanced Usage

Sosialite have options for use with framework and middleware

Set Request

Interface: \Psr\Http\Message\ServerRequestInterface

Socialite::driver('twitter', $config)
    ->setRequest($this->request);

Set Session

need one of the following read/write interfaces.

write
$session->put()
$session->set()
$session->write()
read
$session->get()
$session->read()
Socialite::driver('twitter', $config)
    ->setSession($this->request->getSession());

Redirect psr7 response

Psr\Http\Message\ResponseInterface will be returned

Socialite::driver('twitter', $config)->psr7Redirect()
You can’t perform that action at this time.