jdelaune/oauth2-client-bundle
Symfony bundle that wraps the PHP League OAuth2 client, letting you configure OAuth2 providers as services and use them to run authorization flows and retrieve access tokens in your application. A lightweight way to wire OAuth2 clients into Symfony.
Architecture fit — poor (primary blocker). This is a Symfony bundle, not a Laravel package. It ships the classic Symfony packaging triple — a Bundle class, a DependencyInjection\Extension with a Configuration tree, and compiler passes — none of which Laravel's container or bootstrap lifecycle understands. Laravel consumes Symfony components (HttpFoundation, Routing, Console, EventDispatcher) but does not consume Symfony bundles. There is no bundles.php, no kernel bundle registration, no services.yaml autoloading. So the install path is not "composer require and go"; it is "read the bundle's ~few hundred lines of glue and rewrite them as a service provider."
What is actually reusable. The bundle is a thin wrapper. The substance underneath is league/oauth2-client plus provider-specific packages (league/oauth2-google, thenetworg/oauth2-azure, etc.), and those are framework-agnostic, actively maintained, and widely deployed. The genuinely valuable asset here is the pattern (a client factory keyed by provider name, a registry/container binding, config-driven provider resolution), not the code.
Integration feasibility — feasible but reimplementation, not integration. Effort is small: a config file (config/oauth2.php), a singleton factory binding, a token repository, a callback controller, and a provider resolver. Realistic sizing is 2–4 engineering days including tests, assuming the underlying league providers cover the target IdPs. The bundle itself is a 2019-era Symfony 2–4 artifact; its composer.json constraints and any Symfony DI/Config API usage will not resolve against a modern Laravel app's dependency graph without forking and patching.
Technical risk — medium-high, concentrated in provenance rather than code.
Key questions before any build decision.
league/oauth2-client directly, no bundle)?league/* dependency chain?Recommendation: treat this package as reference material, not a dependency. The 0.245 score is consistent with what the metadata shows — unmaintained, framework-mismatched, zero adoption.
Stack fit — no direct fit; consume the abstraction, drop the wrapper. A Laravel application already has everything the bundle provides: configuration via config/, singletons via the service container, HTTP via Illuminate\Http\Client, session/state via the session store, and routing via the router. The bundle's contribution collapses to a factory + registry, roughly 100–200 lines of Laravel-native code.
Migration path.
league/oauth2-client ^2.7 plus the specific provider packages. Pin minor versions and record them.Oauth2ClientFactory as a container singleton resolving provider name → configured AbstractProvider, driven by config/oauth2.php with env-backed client_id/client_secret/redirect_uri.TokenStore contract with a database-backed implementation; encrypt access/refresh tokens at rest using Laravel's encrypted cast.state validation (and PKCE where the provider supports it).Guard/UserProvider rather than bolting auth onto the controller.Compatibility. Verify PHP floor against the target runtime; league/oauth2-client v2 supports PHP 7.2+ and runs on 8.x, but the bundle's own constraints will conflict. Do not attempt to keep the bundle in the tree alongside Laravel — the DI extension will either never execute (dead code) or, worse, get autoloaded and fail on missing Symfony Kernel classes.
Sequencing. Spike the chosen provider end-to-end first (half a day, real credentials, real callback) to confirm scopes, redirect URI registration, and token response shape before building the abstraction. Then generalize to the registry, then add persistence, then tests, then cutover. Do not build a multi-provider abstraction on a single unvalidated provider.
Maintenance — the dominant cost, and it is structural. With no upstream releases since 2019 and zero dependents, there is no maintenance tail to ride. Any fork becomes a first-class owned artifact requiring dependency-bump PRs and a security watch on league/oauth2-client and its provider packages. The Laravel-native rewrite avoids this entirely: league/oauth2-client has an active maintainer base and predictable release cadence.
Support. No vendor, no SLA, no community. Documentation is a README and the Symfony docs for a framework the target stack does not use. On-call runbooks must be written from scratch. Budget a named owner for the OAuth surface regardless of path chosen — this is auth-adjacent code and should not be orphaned.
Scaling. Token acquisition is outbound HTTP to the IdP, so the IdP's rate limits, not application capacity, govern throughput. Two things to design in early: (a) cache provider metadata/discovery documents rather than fetching per request; (b) serialize refresh per user to avoid concurrent refresh storms invalidating rotating refresh tokens. Session-backed token storage will not scale across horizontally scaled instances without a shared session store.
Failure modes to plan for.
Http:: request dumps or exception payloads — scrub explicitly.Ramp-up. Low. The rewritten surface is small and idiomatic Laravel, so a mid-level engineer can own it within a sprint. The bundle itself has a steeper read cost precisely because Symfony DI extension and compiler-pass idioms are unfamiliar to most Laravel developers — an argument against inheriting it even if the code were current.
How can I help you explore Laravel packages today?