PHPackages                             xepeng/oauth-php - 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. xepeng/oauth-php

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

xepeng/oauth-php
================

Xepeng OAuth PHP SDK

v1.0.2(3mo ago)04MITPHPPHP ^7.4 || ^8.0

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/syaifudin21/xepeng-oauth-php)[ Packagist](https://packagist.org/packages/xepeng/oauth-php)[ RSS](/packages/xepeng-oauth-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Xepeng OAuth PHP SDK
====================

[](#xepeng-oauth-php-sdk)

A PHP library for integrating with Xepeng OAuth authentication.

Installation
------------

[](#installation)

```
composer require xepeng/oauth-php
```

Basic Usage (Vanilla PHP)
-------------------------

[](#basic-usage-vanilla-php)

```
use Xepeng\OAuth\Client;

session_start();

$client = new Client([
    'client_id' => 'your-client-id',
    'client_secret' => 'your-client-secret',
    'redirect_uri' => 'http://your-app.com/callback',
    'env' => 'production', // optional, defaults to 'development'
    'scopes' => ['profile', 'email'], // optional
]);

// 1. Redirect to authorization URL
if (!isset($_GET['code'])) {
    $authUrl = $client->getAuthorizationUrl();
    header('Location: ' . $authUrl);
    exit;
}

// 2. Handle callback
try {
    $tokenResponse = $client->handleCallback();

    // Access token is automatically stored in session
    $accessToken = $tokenResponse['access_token'];

    // Get user info (Optional)
    // $user = $client->getUserInfo();

    echo "Authentication successful!";

} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

Laravel Integration
-------------------

[](#laravel-integration)

To use this package in a Laravel project, follow these steps to integrate gracefully with Laravel's session and routing.

### 1. Configuration

[](#1-configuration)

Add your Xepeng credentials to your `.env` file:

```
XEPENG_CLIENT_ID=your_client_id
XEPENG_CLIENT_SECRET=your_client_secret
XEPENG_REDIRECT_URI=http://your-app-url/callback/xepeng
XEPENG_ENV=development
```

Create a config file `config/xepeng.php`:

```
return [
    'client_id' => env('XEPENG_CLIENT_ID'),
    'client_secret' => env('XEPENG_CLIENT_SECRET'),
    'redirect_uri' => env('XEPENG_REDIRECT_URI'),
    'env' => env('XEPENG_ENV', 'development'),
];
```

### 2. Session Adaptor

[](#2-session-adaptor)

Create a service to bridge the package's storage interface with Laravel's session. `app/Services/LaravelSessionStorage.php`:

```
namespace App\Services;

use Xepeng\OAuth\Storage\StorageInterface;
use Illuminate\Support\Facades\Session;

class LaravelSessionStorage implements StorageInterface
{
    private string $prefix;

    public function __construct(string $prefix = 'xepeng_oauth_')
    {
        $this->prefix = $prefix;
    }

    public function set($key, $value)
    {
        Session::put($this->prefix . $key, $value);
    }

    public function get($key)
    {
        return Session::get($this->prefix . $key);
    }

    public function remove($key)
    {
        Session::forget($this->prefix . $key);
    }

    public function clear()
    {
        Session::forget($this->prefix . 'tokens');
        Session::forget($this->prefix . 'oauth_state');
    }

    public function has($key)
    {
        return Session::has($this->prefix . $key);
    }
}
```

### 3. Controller

[](#3-controller)

Create a controller to handle the flow. `app/Http/Controllers/XepengOAuthController.php`:

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Xepeng\OAuth\Client;
use App\Services\LaravelSessionStorage;

class XepengOAuthController extends Controller
{
    private $client;

    public function __construct()
    {
        $config = config('xepeng');

        $this->client = new Client([
            'client_id' => $config['client_id'],
            'client_secret' => $config['client_secret'],
            'redirect_uri' => $config['redirect_uri'],
            'env' => $config['env'],
            'storage_adapter' => new LaravelSessionStorage(),
        ]);
    }

    public function redirect()
    {
        return redirect()->away($this->client->getAuthorizationUrl());
    }

    public function callback(Request $request)
    {
        try {
            $tokenResponse = $this->client->handleCallback($request->all());

            return response()->json([
                'message' => 'Authentication successful',
                'tokens' => $tokenResponse
            ]);
        } catch (\Exception $e) {
            return response()->json(['error' => $e->getMessage()], 400);
        }
    }
}
```

### 4. Routes

[](#4-routes)

Add routes in `routes/web.php`:

```
Route::get('/login/xepeng', [\App\Http\Controllers\XepengOAuthController::class, 'redirect']);
Route::get('/callback/xepeng', [\App\Http\Controllers\XepengOAuthController::class, 'callback']);
```

Custom Storage
--------------

[](#custom-storage)

You can implement `Xepeng\OAuth\Storage\StorageInterface` to use your own storage mechanism (e.g. database, Redis).

```
use Xepeng\OAuth\Client;
use My\Custom\Storage;

$client = new Client([
    // ... other config
    'storage_adapter' => new Storage(),
]);
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance82

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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 ~0 days

Total

3

Last Release

97d ago

### Community

Maintainers

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

---

Top Contributors

[![syaifudin21](https://avatars.githubusercontent.com/u/35588067?v=4)](https://github.com/syaifudin21 "syaifudin21 (3 commits)")

### Embed Badge

![Health badge](/badges/xepeng-oauth-php/health.svg)

```
[![Health](https://phpackages.com/badges/xepeng-oauth-php/health.svg)](https://phpackages.com/packages/xepeng-oauth-php)
```

###  Alternatives

[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[rahul900day/laravel-captcha

Different types of Captcha implementation for Laravel Application.

10715.9k](/packages/rahul900day-laravel-captcha)[simplesamlphp/simplesamlphp-module-oidc

A SimpleSAMLphp module adding support for the OpenID Connect protocol

5016.9k1](/packages/simplesamlphp-simplesamlphp-module-oidc)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)[descope/descope-php

Descope SDK for PHP

3814.0k](/packages/descope-descope-php)[njoguamos/laravel-turnstile

A laravel wrapper for https://developers.cloudflare.com/turnstile/

2315.9k2](/packages/njoguamos-laravel-turnstile)

PHPackages © 2026

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