dev-ratna/phalcon-social

a phalcon component to implement social logins

Maintainers

Package info

github.com/dev-ratna/phalconsocial

pkg:composer/dev-ratna/phalcon-social

Statistics

Installs: 16

Dependents: 0

Suggesters: 0

Stars: 6

Open Issues: 0

dev-master 2017-05-09 18:06 UTC

This package is not auto-updated.

Last update: 2026-03-15 09:35:46 UTC


README

Social Login Wrapper for Phalcon (Based on Laravel's Socialite)

Installation

composer require dev-ratna/phalcon-social

Configration

the wrapper by deafault searches for social key in the main config file.

the config should use keys facebook, google or depending on the alias of the provider.

'social' => [
  'facebook' => [
        'client_id' => 'client-id-here',
        'client_secret' => 'client-secret-here',
        'redirect_uri' => 'url/to/redirect'
    ],
    'google' => [
        'client_id' => 'example-id',
        'client_secret' => 'example-secret',
        'redirect_uri' => 'url/to/redirect'
    ]
  ]

Usage

The Service

use PhalconSocial\PhalconSocial;

$di->setShared('socialLogin', function(){
    $socialLogin = new SocialLogin();
    return $socialLogin;

});

The routes

$router->add('/social/oauth/redirect', [
	'controller' => 'controller',
	'action' => 'redirect'
]);

$router->add('/social/oauth/login', [
	'controller' => 'controller',
	'action' => 'login'
]);

In the Controller

<?php

namespace Namespace\Controllers;


class Controller extends ControllerBase
{

    public function redirectAction()
    {
        $this->socialLogin->useProvider('google')->redirect();
    }

    public function loginAction()
    {
    	$user = $this->socialLogin->useProvider('google')->authorize()->user();
    }
}

Adding your own providers

In works.

Currently the package only supports google and facebook, more are to come soon.