overtrue/laravel-socialite
Composer 安装命令:
composer require overtrue/laravel-socialite
包简介
Social OAuth authentication for Laravel 5.
README 文档
README
Installation
$ composer require "overtrue/laravel-socialite"
if you have been installed the
overtrue/socialitepackage, please remove it fromcomposer.jsonbefore this command.
Configuration
- You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your
config/socialite.phporconfig/services.phpconfiguration file, and should use the key facebook, twitter, linkedin, google, github or bitbucket, depending on the providers your application requires. For example:
<?php return [ //... 'github' => [ 'client_id' => 'your-app-id', 'client_secret' => 'your-app-secret', 'redirect' => 'http://localhost/socialite/callback.php', ], //... ];
Usage
<?php namespace App\Http\Controllers; use Socialite; use Illuminate\Http\Request; use Illuminate\Routing\Controller; class AuthController extends Controller { /** * Redirect the user to the GitHub authentication page. */ public function redirectToProvider() { return redirect()->to(Socialite::create('github')->redirect()); } /** * Obtain the user information from GitHub. */ public function handleProviderCallback(Request $request) { $user = Socialite::create('github')->userFromCode($request->query('code')); // $user->getId(); // $user->getNickname(); // ... } }
And register routes:
Route::get('/oauth/github', 'AuthController@redirectToProvider'); Route::get('/oauth/github/callback', 'AuthController@handleProviderCallback');
About more usage, please refer to overtrue/socialite.
❤️ Sponsor me
如果你喜欢我的项目并想支持它,点击这里 ❤️
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
PHP 扩展包开发
想知道如何从零开始构建 PHP 扩展包?
请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》
License
MIT
overtrue/laravel-socialite 适用场景与选型建议
overtrue/laravel-socialite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.27M 次下载、GitHub Stars 达 344, 最近一次更新时间为 2015 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 overtrue/laravel-socialite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 overtrue/laravel-socialite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.27M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 347
- 点击次数: 28
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-10