carry0987/falcon
Composer 安装命令:
composer require carry0987/falcon
包简介
Falcon - A versatile PHP framework designed for seamless integration of third-party social logins. Supports major services including Google, Facebook, Twitter, etc, delivering simple and secure authentication via a unified interface and design patterns.
README 文档
README
Falcon is a versatile PHP framework designed for seamless integration of third-party social platform login mechanisms.
It offers simple and secure user authentication through a unified interface and design patterns, making it easy to implement and maintain.
Currently, it supports the following major services:
- GitHub
- Discord
- Line
- Telegram
Whether you're developing a new application or enhancing an existing system, Falcon can help you quickly implement social login features while ensuring user data security and privacy.
Features
- Unified Interface: Operate all supported social services using standardized methods.
- Easy Integration: Integrate quickly into your project with intuitive configuration and clear documentation.
- Security: Implements the best current security practices to safeguard the login process and data.
- Flexible Design: Easily add or remove specific social services without affecting the existing system architecture.
- Open Source Support: Benefit from the continuous improvements and support of the open-source community.
Installation
Install Falcon into your project with Composer:
composer require carry0987/falcon
Usage Example
First, set up the credentials and other configuration information for each third-party service in your project:
$config = [ 'providers' => [ 'github' => [ 'client_id' => 'your_github_client_id', 'client_secret' => 'your_github_client_secret', 'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=github' ], 'line' => [ 'client_id' => 'your_line_client_id', // Channel ID 'client_secret' => 'your_line_client_secret', // Channel secret 'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=line' ], 'telegram' => [ 'client_id' => 'your_telegram_client_id', // Bot username 'client_secret' => 'your_telegram_client_secret', // Bot token 'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=telegram' ], // Configuration for other third-party login providers... ], ];
Next, create an instance of Falcon and initiate the login process with the chosen third-party provider:
$falcon = new \carry0987\Falcon\Falcon($config); $providerName = $_GET['provider'] ?? 'default'; $provider = $falcon->createProvider($providerName); // Start the OAuth login process if (!isset($_GET['code'])) { $loginUrl = $provider->authorize(); // Redirect user to the login page header('Location: ' . $loginUrl); exit; } // Handle the callback and retrieve user information if ($providerName === 'telegram') { // Special handling for Telegram login flow... } else { $accessToken = $provider->getTokenWithAuthCode($_GET['code']); $user = $provider->getUser(); // Output user information echo "<pre>" . print_r($user, true) . "</pre>"; }
To end the login session, you can revoke the access token:
if (isset($_GET['logout'])) { $provider->revokeAccessToken($_GET['access_token'] ?? null); // Redirect back to the login page or homepage header('Location: ?provider=' . $providerName); exit; }
You can add more standard OAuth processing logic to your code, such as handling error states, redirecting to other pages, etc.
Support
If you have any issues, please open an issue on our GitHub repository.
Enjoy using Falcon in your project!
carry0987/falcon 适用场景与选型建议
carry0987/falcon 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 carry0987/falcon 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 carry0987/falcon 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 80
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-30