freebuu/socialite-local

Socialite provider for local development
1,014 1
Install
composer require freebuu/socialite-local
Latest Version:v1.2.0
PHP:^7.4 || ^8.0
License:MIT
Last Updated:Dec 23, 2025
Links: GitHub  ·  Packagist
Maintainer: freebuu

Socialite Local

Introduction

The library is used to simulate an OAuth server locally. All calls to the Socialite are intercepted and replaced by a local driver. Only installation is enough to use - no additional configuration in most cases.

Installation

  • Require Socialite v4 or v5 and OAuth2 provider (OAuth1 providers not supported for now)
  • Use Composer to install: composer require --dev freebuu/socialite-local

:warning: WARNING: install this package only as dev dependency due to security reasons.

By default, the package is disabled in production (when APP_ENV=production). You can explicity control if the interceptor is enabled by setting SOCIALITE_LOCAL_ENABLED=true (or false) in your environment file.

Usage

Just use socialite as usual:

Socialite::driver('github')->redirect()

You will be redirected to local page - where you can set email, username, id, etc. for subject. After submitting form you can get socialite user as usual - with previously entered data.

Socialite::driver('github')->user()

Additional configuration

Server response

If you need to imitate user structure from server - it can be achieved with afterResolving callback

public function register()
{
    $this->app->afterResolving('socialite_local.subject_repository', function ($r){
        $r->setUserCallback(function ($data){
            //data is array coming from login form
            //return array with user info
            return [
                'id' => $data['id'] ?? random_int(1000, 10000),
                'uuid' => $data['uuid'] ?? vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)),
                'email' => $email = $data['email'],
                'username' => $data['username'] ?? $email,
                'name' => $data['name'] ?? mb_substr($email, 0, strpos($email, '@')) . '_name',
            ];
        });
    });
}

User mapper

By default, library use original driver mapper - to map server answer to User model. You can disable this behavior by setting SOCIALITE_LOCAL_USE_ORIGINAL_MAPPER to false

Related Packages

laravel-uis/socialite-ui

A Laravel Socialite UI for the new Laravel Starter Kits

10,553 11
socialiteproviders/linkedin

LinkedIn OAuth2 Provider for Laravel Socialite

1,795,150 12
socialiteproviders/instagram

Instagram OAuth2 Provider for Laravel Socialite

2,145,901 40
socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

55,953,736 426

Version History

Version Released PHP Laravel License
v1.2.0 ^7.4 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10 || ^11 || ^12 MIT
v1.1.0 ^7.4 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10 || ^11 || ^12 MIT
v1.0.0 ^7.4 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10 || ^11 MIT
Pre-releases (2)
Version Released PHP Laravel License
v0.1.1-alpha ^7.4 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10 MIT
v0.1.0-alpha ^7.4 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10 MIT