PHPackages                             gelembjuk/auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. gelembjuk/auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

gelembjuk/auth
==============

PHP Package for easy login to a web site with popular social networks. Now supports login with Facebook, Google, Twitter, LinkedIn.

2.0.1(1y ago)569811MITPHP

Since Jul 29Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Gelembjuk/auth)[ Packagist](https://packagist.org/packages/gelembjuk/auth)[ RSS](/packages/gelembjuk-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (13)Used By (1)

Gelembjuk/Auth package
----------------------

[](#gelembjukauth-package)

PHP Package for easy login to a web site with popular social networks.

Now supports login with Facebook, Google, Twitter, LinkedIn, Xing.

### Installation

[](#installation)

Using composer: [gelembjuk/auth](http://packagist.org/packages/gelembjuk/auth) `require: {"gelembjuk/auth": "*"}`

### Configuration

[](#configuration)

You need to get API keys for each of social networks.

Details on how to register application and get keys for each social network.

**Twitter** Register your application there  . Copy Consumer Key and Secret Key in your application settings.

**LinkedIn** Go to , Then "My Apps". Create new App. Copy API Key and Secret. You need to set Authorized Redirect URLs. It will be an url to your "Login complete script".

**Facebook** Go to . "Add new App" as Web-Page. Copy API Key and Secret. Enable "Web OAuth Login".

**Google** Go to . Create new Project. Enable Google+ API in this project in the APIs section. Then Create new Client ID in Credentials section. Choose "Web Application". Set up redirect url , it will be an url to your "Login complete script". Copy Client ID , Client Secret

**NOTE**. For some social networks it is needed to provide a correct login redirect url (callback url) in an application settings when you registering new keys. For example, you have to do this is Google API Console.

Login redirect url is a "complete login" url in your app. A script where you do final actions on a social login.

Recommended is to keep all integration options in one array in a separate safe configuration file. It is not required to have all integrations keys. Add only what you really need.

```
$integrations = array(
	'facebook' => array(
		'api_key' => 'fake facebook api key',
		'secret_key' => 'fake facebook secret key'
		),
	'twitter' => array(
		'consumer_key' => 'fake twitter consumer key',
		'consumer_secret' => 'fake twitter consumer secret'
		),
	'linkedin' => array(
		'api_key' => 'fake linkedin api key',
		'api_secret' => 'fake linkedin api secret'
		),
	'google' => array(
		'application_name' => 'Your application name',
		'client_id' => 'fake google api client id',
		'client_secret' => 'fake google api client secret'
		),
	'xingapi' => array(
		'consumer_key' => 'fake xing consumer key',
		'consumer_secret' => 'fake xing counsumer secret'
		),
	'liveid' => array(
		'consumer_key' => 'fake live id consumer key',
		'consumer_secret' => 'fake live id consumer secret'
		)
	);
```

### Usage

[](#usage)

#### Start login process.

[](#start-login-process)

File startlogin.php

```
// composer autoloader
require '../vendor/autoload.php';

$socialnetwork = $_REQUEST['network'];  // this is one of: facebook, google, twitter, linkedin

// create social network login object. The second argument is array of API settings for a social network
$network = Gelembjuk\Auth\AuthFactory::getSocialLoginObject($socialnetwork,$integrations[$socialnetwork]);

$redirecturl = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']).'/completelogin.php';

$socialauthurl = $network->getLoginStartUrl($redirecturl);

// remember the state. it will be used when complete a social login
$_SESSION['socialloginsate_'.$socialnetwork] = $network->serialize();

// this is optional. you can include a network name in your redirect url and then extract
$_SESSION['socialloginnetwork'] = $socialnetwork;

header("Location: $socialauthurl",true,301);
exit;
```

#### Complete login process.

[](#complete-login-process)

File completelogin.php

```
// composer autoloader
require '../vendor/autoload.php';

$socialnetwork = $_SESSION['socialloginnetwork'];

$network = Gelembjuk\Auth\AuthFactory::getSocialLoginObject($socialnetwork,$integrations[$socialnetwork]);

try {
	// read some input parameters needed to complete auth by this social network
	$arguments = array();

	foreach ($network->getFinalExtraInputs() as $key) {
		$arguments[$key] = $_REQUEST[$key];
	}

	// restore to a state before redirect
	$network->unSerialize($_SESSION['socialloginsate_'.$socialnetwork]);

	// get authorized user short social profile
	$profile = $network->completeLogin($arguments);

	// save user info to a session
	$_SESSION['user'] = $profile;

	// now user is loged in!

	//redirect user to home page
	header("Location: index.php",true,301);
	exit;

} catch (Exception $e) {
	echo "Somethign went wrong during the login process";
	echo "Error is: ".$e->getMessage();
}
```

### Author

[](#author)

Roman Gelembjuk (@gelembjuk)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance46

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~321 days

Recently: every ~196 days

Total

12

Last Release

406d ago

Major Versions

1.2.0 → 2.0.12025-04-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/af567529d048ed36455232a1f1ec9aaa9addb8eef9fb79f14acd4dbf614573a3?d=identicon)[gelembjuk](/maintainers/gelembjuk)

---

Top Contributors

[![Gelembjuk](https://avatars.githubusercontent.com/u/1552191?v=4)](https://github.com/Gelembjuk "Gelembjuk (29 commits)")

---

Tags

facebookgoogletwitterlinkedinSocial Login

### Embed Badge

![Health badge](/badges/gelembjuk-auth/health.svg)

```
[![Health](https://phpackages.com/badges/gelembjuk-auth/health.svg)](https://phpackages.com/packages/gelembjuk-auth)
```

###  Alternatives

[hwi/oauth-bundle

Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony.

2.4k21.5M69](/packages/hwi-oauth-bundle)[fof/oauth

Allow users to log in with GitHub, Facebook, Google, Discord, GitLab, LinkedIn, and more!

50118.7k41](/packages/fof-oauth)[and/oauth

Simple and amazing OAuth library with many providers. Just try it out!

4645.2k2](/packages/and-oauth)[dukt/social

Let your visitors log into Craft with web services like Facebook, Google, Twitter…

1141.0k5](/packages/dukt-social)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
