lijinhua / hyperf-socialite
适用于hyperf的社会化登录
v1.0.2
2023-11-08 06:33 UTC
Requires
- php: >=8.0
- ext-openssl: *
- firebase/php-jwt: ^5.2
- hyperf/cache: ^3.0
- hyperf/di: 3.0.*
- hyperf/framework: 3.0.*
- hyperf/guzzle: ^3.0
- hyperf/http-server: ^3.0
- hyperf/logger: ^3.0
- lcobucci/jwt: ^4.0
- league/oauth1-client: ^1.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2025-03-08 09:18:13 UTC
README
About
改造自cblink/hyperf-socialite, 新增了一些组件(apple,...)
Installing
# 安装 composer require lijinhua/hyperf-socialite -vvv # 创建配置文件 php bin/hyperf.php vendor:publish lijinhua/hyperf-socialite
Configure
配置文件位于 config/autoload/socialite.php
,如文件不存在可自行创建
<?php return [ // 需要加载的provider 'providers' => [ // \HyperfSocialiteProviders\Feishu\Provider::class, ], 'config' => [ 'facebook' => [ 'client_id' => '', 'client_secret' => '', // 其他provider中需要使用的配置 // ... ], // qq,weixin... ]() ], ];
Usage
控制器中使用
<?php use Lijinhua\HyperfSocialite\Contracts\SocialiteInterface; class Controller { /** * @param SocialiteInterface $socialite * @return \Hyperf\HttpServer\Contract\ResponseInterface */ public function redirectToProvider(SocialiteInterface $socialite) { // 重定向跳转 $redirect = $socialite->driver('facebook')->redirect(); // 使用新的配置跳转 $socialite->driver('facebook')->setConfig([ 'client_id' => 'xxx', 'client_secret' => 'xxxx', ]) return $redirect; } /** * @param SocialiteInterface $socialite */ public function handleProviderCallback(SocialiteInterface $socialite) { // 获取用户信息 $user = $socialite->driver('facebook')->user(); // // $user->token; } }
支持的列表
支持应用 | 驱动名称 |
---|---|
微博 | |
YouTube | youtube |
飞书自建应用 | feishu |
微信公众号 | weixin |
微信PC网站登陆 | weixinweb |
微信开放平台代公众号授权 | wechat_service_account |
企业微信第三方应用扫码 | third_weworkqr |
企业微信 | wework |
企业微信自建应用扫码 | weworkqr |
苹果 | apple |