承接 fuziion/riot-games-sso 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fuziion/riot-games-sso

Composer 安装命令:

composer require fuziion/riot-games-sso

包简介

A simple and efficient PHP package for implementing Riot Games SSO authentication. Works with any PHP framework (Laravel, Symfony, CodeIgniter) or plain PHP projects.

README 文档

README

Latest Version Total Downloads License

A simple and efficient PHP package for implementing Riot Games SSO (Single Sign-On) authentication. Works with any PHP project including Laravel, Symfony, CodeIgniter, or plain PHP. This package uses native PHP cURL, requiring no external HTTP client dependencies.

Features

  • Zero Dependencies - Uses native PHP cURL, no Guzzle or other HTTP clients required
  • Laravel Integration - Seamless integration with Laravel via Service Provider and Facade
  • Framework Agnostic - Can be used in any PHP project
  • Simple API - Clean and intuitive methods for OAuth flow
  • Error Handling - Comprehensive exception handling
  • Type Safe - Full type hints and return types

Installation

Install the package via Composer:

composer require fuziion/riot-games-sso

Quick Start

Plain PHP / Framework Agnostic Usage

The package works out of the box in any PHP project. Simply instantiate the class with your credentials:

💡 Tip: See EXAMPLE_STANDALONE.php for a complete working example in a standalone PHP project.

require 'vendor/autoload.php';

use Fuziion\RiotGamesSSO\RiotGames;
use Fuziion\RiotGamesSSO\Exceptions\RiotGamesException;

// Initialize with your credentials
$riotGames = new RiotGames(
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret'
);

try {
    // Step 1: Get authorization URL and redirect user
    $authUrl = $riotGames->getAuthorizationUrl('https://yourapp.com/callback');
    header("Location: {$authUrl}");
    exit;
    
    // Step 2: Handle callback (after user authorizes)
    $code = $_GET['code'] ?? null;
    if ($code) {
        $accessToken = $riotGames->getRiotAuthToken($code, 'https://yourapp.com/callback');
        
        if ($accessToken) {
            $accountData = $riotGames->getRiotAccountData($accessToken);
            $accountData['puuid'] - Player UUID
            $accountData['gameName'] - In-game name
            $accountData['tagLine'] - Tag line
        }
    }
} catch (RiotGamesException $e) {
    echo "Error: " . $e->getMessage();
}

Laravel Setup

  1. Publish the configuration file (optional):
php artisan vendor:publish --tag=riot-games-sso-config
  1. Add your Riot Games credentials to your .env file:
RIOT_GAMES_CLIENT_ID=your_client_id
RIOT_GAMES_CLIENT_SECRET=your_client_secret

The service provider and facade are auto-discovered, so no manual registration is needed.

Usage

Laravel Usage

Using the Facade

use Fuziion\RiotGamesSSO\Facades\RiotGames;

// Redirect user to Riot Games login
public function redirectToRiot()
{
    $callbackUrl = route('riot.callback');
    return redirect(RiotGames::getAuthorizationUrl($callbackUrl));
}

// Handle the callback
public function handleCallback(Request $request)
{
    try {
        $code = $request->get('code');
        $callbackUrl = route('riot.callback');
        
        // Exchange code for access token
        $accessToken = RiotGames::getRiotAuthToken($code, $callbackUrl);
        
        if ($accessToken) {
            // Get user account data
            $accountData = RiotGames::getRiotAccountData($accessToken);
            
            // $accountData contains:
            // - puuid: Player UUID
            // - gameName: In-game name
            // - tagLine: Tag line
            
            // Handle user authentication/login here
            // ...
        }
    } catch (\Fuziion\RiotGamesSSO\Exceptions\RiotGamesException $e) {
        // Handle error
        return redirect()->back()->with('error', $e->getMessage());
    }
}

Using Dependency Injection

use Fuziion\RiotGamesSSO\RiotGames;

class RiotAuthController extends Controller
{
    public function __construct(
        protected RiotGames $riotGames
    ) {}
    
    public function redirectToRiot()
    {
        $callbackUrl = route('riot.callback');
        return redirect($this->riotGames->getAuthorizationUrl($callbackUrl));
    }
    
    public function handleCallback(Request $request)
    {
        $code = $request->get('code');
        $callbackUrl = route('riot.callback');
        
        $accessToken = $this->riotGames->getRiotAuthToken($code, $callbackUrl);
        $accountData = $this->riotGames->getRiotAccountData($accessToken);
        
        // Handle authentication...
    }
}

Other PHP Frameworks (Symfony, CodeIgniter, etc.)

The package works the same way in any PHP framework. Just instantiate the class with your credentials:

use Fuziion\RiotGamesSSO\RiotGames;
use Fuziion\RiotGamesSSO\Exceptions\RiotGamesException;

// In your controller or service
$riotGames = new RiotGames(
    clientId: getenv('RIOT_GAMES_CLIENT_ID'),
    clientSecret: getenv('RIOT_GAMES_CLIENT_SECRET')
);

// Get authorization URL
$authUrl = $riotGames->getAuthorizationUrl('https://yourapp.com/callback');

// Exchange code for token
$accessToken = $riotGames->getRiotAuthToken($code, $redirectUri);

// Get account data
$accountData = $riotGames->getRiotAccountData($accessToken);

API Reference

Methods

getAuthorizationUrl(string $redirectUri, array $scopes = ['openid', 'offline_access', 'email']): string

Generate the authorization URL for redirecting users to Riot Games login.

Parameters:

  • $redirectUri - The callback URL where Riot will redirect after authentication
  • $scopes - Optional array of OAuth scopes (default: openid, offline_access, email)

Returns: The full authorization URL

getRiotAuthToken(string $code, string $redirectUri): string|null

Exchange the authorization code for an access token.

Parameters:

  • $code - The authorization code from the callback
  • $redirectUri - The redirect URI used in the authorization request (must match exactly)

Returns: The access token or null if not found

Throws: RiotGamesException on error

getRiotAccountData(string $accessToken): array

Get user account data using the access token.

Parameters:

  • $accessToken - The OAuth access token

Returns: Array containing:

  • puuid - Player UUID
  • gameName - In-game name
  • tagLine - Tag line

Throws: RiotGamesException on error

Example Routes (Laravel)

// routes/web.php
Route::get('/auth/riot', [RiotAuthController::class, 'redirectToRiot'])->name('riot.login');
Route::get('/auth/riot/callback', [RiotAuthController::class, 'handleCallback'])->name('riot.callback');

Error Handling

The package throws RiotGamesException for all errors. Always wrap calls in try-catch blocks:

use Fuziion\RiotGamesSSO\Exceptions\RiotGamesException;

try {
    $accessToken = RiotGames::getRiotAuthToken($code, $redirectUri);
} catch (RiotGamesException $e) {
    // Handle error
    // $e->getMessage() contains the error message
    // $e->getCode() contains the HTTP status code (if applicable)
}

Requirements

  • PHP 8.1 or higher
  • cURL extension enabled
  • Riot Games Developer Account with OAuth credentials

Getting Riot Games Credentials

  1. Visit the Riot Games Developer Portal
  2. Create a new application
  3. Configure your redirect URI
  4. Copy your Client ID and Client Secret

License

This package is open-sourced software licensed under the MIT license.

Author

Diederik Veenstra (fuziion_dev)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please open an issue on GitHub.

fuziion/riot-games-sso 适用场景与选型建议

fuziion/riot-games-sso 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「Authentication」 「oauth」 「SSO」 「laravel」 「riot-games」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fuziion/riot-games-sso 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fuziion/riot-games-sso 我们能提供哪些服务?
定制开发 / 二次开发

基于 fuziion/riot-games-sso 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-18