PHPackages                             hocnt84/oauth2-server-httpfoundation-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. hocnt84/oauth2-server-httpfoundation-bridge

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

hocnt84/oauth2-server-httpfoundation-bridge
===========================================

A bridge to HttpFoundation for oauth2-server-php

v1.3.03(8y ago)014MITPHPPHP &gt;=5.3.0

Since Mar 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/hocnt84/oauth2-server-httpfoundation-bridge)[ Packagist](https://packagist.org/packages/hocnt84/oauth2-server-httpfoundation-bridge)[ Docs](http://github.com/bshaffer/oauth2-server-httpfoundation-bridge)[ RSS](/packages/hocnt84-oauth2-server-httpfoundation-bridge/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (2)Versions (14)Used By (0)

oauth2-server-httpfoundation-bridge
===================================

[](#oauth2-server-httpfoundation-bridge)

A bridge to [HttpFoundation](https://github.com/symfony/httpfoundation) for [oauth2-server-php](https://github.com/bshaffer/oauth2-server-php).

[![Build Status](https://camo.githubusercontent.com/79c51e66bffdbd794ed39775550c968fcf777a269d7713be217b8f1a5a486043/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f62736861666665722f6f61757468322d7365727665722d68747470666f756e646174696f6e2d6272696467652e706e67)](http://travis-ci.org/bshaffer/oauth2-server-httpfoundation-bridge)

`oauth2-server-httpfoundation-bridge` is a wrapper for [oauth2-server-php](https://github.com/bshaffer/oauth2-server-php)which returns `Symfony\Component\HttpFoundation\Response` instead of `OAuth2\Response`, and uses `Symfony\Component\HttpFoundation\Request` instead of `OAuth2\Request`.

If you are integrating OAuth2 into a Silex, Symfony, or [Laravel 4](http://four.laravel.com) app, (or any app using `HttpFoundation`), this will make your application much cleaner

Installation
------------

[](#installation)

[Composer](http://getcomposer.org/) is the best way to install this library. Add this line to composer.json:

```
{
    "require": {
        "bshaffer/oauth2-server-httpfoundation-bridge": "v1.0",
        ...
    },
    ...
}

```

And then run `composer.phar install`

> Match tags with the [oauth2-server-php](https://github.com/bshaffer/oauth2-server-php) library when possible. [`v1.1`](https://github.com/bshaffer/oauth2-server-httpfoundation-bridge/tree/v1.1) is the latest tag.

Creating the request
--------------------

[](#creating-the-request)

Creating the request object is the same as before, except now you use the `OAuth2\HttpFoundationBridge\Request` class:

```
$request = OAuth2\HttpFoundationBridge\Request::createFromGlobals();
$app->run($request);
```

The Request object is now compatible with both HttpFoundation *and* oauth2-server-php

```
// getBaseUrl is unique to HttpFoundation
$baseUrl = $request->getBaseUrl();

// call oauth server
$server->grantAccessToken($request);
```

If the HttpFoundation request already exists, you can use the static `createFromRequest`function to build the OAuth2\\HttpFoundationBridge\\Request instance:

```
use OAuth2\HttpFoundationBridge\Request as BridgeRequest;

// in your controller layer, the $request object is passed in
public function execute(Request $request)
{
    //... (instantiate server/response objects)
    $bridgeRequest = BridgeRequest::createFromRequest($request);
    $server->grantAccessToken($bridgeRequest, $response);
}
```

Creating the response
---------------------

[](#creating-the-response)

The `OAuth2\HttpFoundationBridge\Response` object extends `Symfony\Component\HttpFoundation\JsonResponse`, and implements `OAuth2\ResponseInterface`, allowing you to pass this in and return it from your controllers. In Symfony and Silex, this will be all that is needed to integrate the server:

```
use OAuth2\HttpFoundationBridge\Response as BridgeResponse;

// in your controller layer, the $request object is passed in
public function execute(Request $request)
{
    //... (instantiate server/response objects)
    $response = new BridgeResponse();
    return $server->handleTokenRequest($request, $response);
}
```

> Note: this object will return JSON. Implement your own class using `OAuth2\ResponseInterface` to support a different content-type.

Examples
--------

[](#examples)

- OAuth2 Request - [Silex Integration](https://github.com/bshaffer/oauth2-demo-php/blob/master/web/index.php#L47)
- OAuth2 Response - [Silex Integration](https://github.com/bshaffer/oauth2-demo-php/blob/master/src/OAuth2Demo/Server/Controllers/Token.php#L26)

Contact
-------

[](#contact)

Please contact Brent Shaffer (bshafs gmail com) for more information

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~184 days

Recently: every ~332 days

Total

11

Last Release

2946d ago

Major Versions

v0.9 → v1.02013-09-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/94f1e0a471bac0f257bc54c613a846bb2563983d001fc901a5a17c27e6db4047?d=identicon)[hocnt84](/maintainers/hocnt84)

---

Top Contributors

[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (49 commits)")[![hocnt84](https://avatars.githubusercontent.com/u/13724833?v=4)](https://github.com/hocnt84 "hocnt84 (6 commits)")[![asierchio](https://avatars.githubusercontent.com/u/10200588?v=4)](https://github.com/asierchio "asierchio (1 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (1 commits)")[![julien-c](https://avatars.githubusercontent.com/u/326577?v=4)](https://github.com/julien-c "julien-c (1 commits)")[![steffkes](https://avatars.githubusercontent.com/u/325361?v=4)](https://github.com/steffkes "steffkes (1 commits)")

---

Tags

authoauthoauth2httpfoundation

### Embed Badge

![Health badge](/badges/hocnt84-oauth2-server-httpfoundation-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/hocnt84-oauth2-server-httpfoundation-bridge/health.svg)](https://phpackages.com/packages/hocnt84-oauth2-server-httpfoundation-bridge)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M247](/packages/league-oauth2-server)[bshaffer/oauth2-server-php

OAuth2 Server for PHP

3.3k15.2M104](/packages/bshaffer-oauth2-server-php)[bshaffer/oauth2-server-httpfoundation-bridge

A bridge to HttpFoundation for oauth2-server-php

522.3M12](/packages/bshaffer-oauth2-server-httpfoundation-bridge)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
