overtrue/socialite
Socialite is a lightweight OAuth2 authentication tool for any PHP project, inspired by laravel/socialite. It supports 20+ platforms including GitHub, Google, Facebook, WeChat, Weibo, QQ, Douyin, Alipay, Apple, and Twitter, letting you redirect users and exchange codes for access tokens and profile d...
SocialiteManager acts as a facade, delegating to provider-specific implementations (e.g., GithubProvider, WechatProvider), adhering to the Strategy Pattern. This aligns well with modern PHP microservices or monolithic apps requiring OAuth2/OIDC flows.ProviderInterface, enabling TPMs to integrate niche platforms (e.g., internal SSO, legacy systems) without forking the package. This reduces vendor lock-in and future-proofs the system.^8.1). Because the package consumes a PSR-18-compatible client rather than hard-coding request internals, TPMs can still inject their own client via withHttpClient(). The architectural fit is unchanged; the dependency floor has moved.overtrue/socialite-psr15) or traditional MVC frameworks (Laravel, Symfony, Slim). For Laravel, the overtrue/laravel-socialite wrapper abstracts further complexity.guzzlehttp/guzzle: ^8.1 (previously ^7.0). Composer cannot resolve this alongside any direct or transitive dependency pinned to ^7.x. Feasibility is therefore gated on a dependency audit of the host application and its full transitive tree, not on the package itself.new \GuzzleHttp\Client([...]) with Guzzle 7 option shapes must be re-validated.['debug' => true] stream option referenced in prior runbooks should be re-verified against Guzzle 8 and, if changed, replaced with PSR-3 logger middleware in the HTTP handler stack.composer why guzzlehttp/guzzle and composer update --dry-run in a branch before committing; treat 4.15.0 as a coordinated platform upgrade, not a routine patch.user()/userFromCode() consumers, but it can surface new static-analysis errors for teams running PHPStan/Psalm at high levels or subclassing QQProvider. Low blast radius, but it will show up as a CI diff.Overtrue\Socialite\Contracts\TokenRepositoryInterface to inject custom storage.component mode, Alipay’s RSA2) require non-standard configurations. Misconfigurations may lead to failed auth flows.
guzzlehttp/guzzle: ^7? If yes, 4.15.0 is not adoptable until that is resolved.mockery) — and do existing test fixtures still apply?overtrue/laravel-socialite for middleware/route helpers. Check the wrapper’s Guzzle constraint — the wrapper may lag the core package and force Guzzle 7 transitively.SocialiteManager in routes.users (local + social IDs).social_accounts (provider-specific tokens).sessions (for token refreshes).composer why guzzlehttp/guzzle across all first-party packages.composer update overtrue/socialite --with-dependencies --dry-run to confirm resolvability.overtrue/socialite to 4.14.* and defer.ProviderInterface.^4.15 → requires Guzzle 8; adopt only after platform-wide Guzzle 8 readiness.4.14.* → last line compatible with Guzzle 7; safe harbor for teams blocked on other SDKs.component mode for third-party platforms.mobile, popup).client_id, client_secret, and redirect_uri securely (e.g., env vars, Vault).$app->get('/auth/github', function () {
$socialite = new SocialiteManager(config('socialite'));
return redirect($socialite->create('github')->redirect());
});
$app->get('/auth/github/callback', function () {
$socialite = new SocialiteManager(config('socialite'));
$user = $socialite->create('github')->userFromCode($_GET['code']);
// Handle user data...
});
state parameter (CSRF protection).code for access_token and fetch user data.$user = $socialite->create('github')->user();
$localUser = User::firstOrCreate(
['email' => $user->getEmail()],
['name' => $user->getName()]
);
$localUser->socialAccounts()->create([
'provider_id' => $user->getId(),
'provider' => 'github',
'token' => $socialite->getAccessToken(),
]);
Overtrue\Socialite\Exceptions\InvalidStateException for CSRF failures.InvalidCredentialsException), and now also transport-layer exceptions from Guzzle 8.access_tokens using refresh_token (if available):
$socialite->create('github')->refreshToken($refreshToken);
debug stream option, which should be re-verified under Guzzle 8:
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(\GuzzleHttp\Middleware::log($logger, new \GuzzleHttp\MessageFormatter()));
$socialite->withHttpClient(new \GuzzleHttp\Client(['handler' => $stack]));
withHttpClient() — defaults may differ between Guzzle majors.| Failure | Symptom | Response |
|---|---|---|
| Unresolvable dependency graph | composer update fails on install |
Pin 4.14.*; defer |
| Guzzle 8 behavioral delta in custom client config | Timeouts / proxy / TLS errors post-deploy | Re-validate client options; canary deploy |
| Mixed Guzzle versions in one app | Class not found / autoload conflicts |
Single-version enforcement in CI |
| QQ return-type strictness | CI static-analysis failure, or type error at runtime | Patch consumer type hints |
| Provider outage | Login failures, 5xx on callback | Provider-specific circuit breaker + fallback auth |
| Token revocation / expiry | Silent auth failures | Refresh flow + user-facing re-consent prompt |
4.14.* (which received patch releases as recently as 4.14.2, indicating the branch is actively maintained) and schedule the Guzzle 8 upgrade as a discrete, tracked platform initiative with an owner and a target quarter.How can I help you explore Laravel packages today?