PHPackages                             marcobuschini/o-auth-bundle - 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. marcobuschini/o-auth-bundle

AbandonedArchivedSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

marcobuschini/o-auth-bundle
===========================

Integrating FOSUserBundle with OAuth

07[5 issues](https://github.com/marcobuschini/MLBOAuthBundle/issues)PHP

Since May 23Pushed 10y ago1 watchersCompare

[ Source](https://github.com/marcobuschini/MLBOAuthBundle)[ Packagist](https://packagist.org/packages/marcobuschini/o-auth-bundle)[ RSS](/packages/marcobuschini-o-auth-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Purpose of this bundle
======================

[](#purpose-of-this-bundle)

I have been very disappointed by the HWIOAuthBundle lately, as it seems its documentation always lacks some essential step to be configured (at leas with my main OAuth provider, which is Google). I just wanted a bundle capable of logging a user in, and registering her, in a very simple way. And this bundle was born.

Install the bundle
==================

[](#install-the-bundle)

At the present moment installation is supported only via git cloning. Create a path under the `vendor` directory named `MLB/OAuthBundle`, and run the following command inside it:

```

$ git clone git://github.com/marcobuschini/MLBOAuthBundle.git .

```

That done, you will have to activate the bundle in the `app/AppKernel.php` file. Simply add the followin line at the end of the `$bundles`:

```

new MLB\OAuthBundle\MLBOAuthBundle()

```

Configure the bundle
====================

[](#configure-the-bundle)

First, and foremost you have to properly install, and configure FOSUserBundle. Get their documentation for that. The minimal configuration required is as follows (goes to `app/config/config.yml`):

```

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Acme\DemoBundle\Entity\User

```

Then we have to configure the OAuth parameters for Google OAuth. Get/set these from your developer console (goes to: `app/config/config.yml`):

```

mlbo_auth:
    google:
        client_id: client id
        client_secret: client secret
        redirect_uri: the url we are waiting the server to respond to our request
        scope: https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile

```

Add the table fields
====================

[](#add-the-table-fields)

What follows is an example user entity definition with all the fields required for running this bundle. In this case we only need the `google_id`, and the `google_access_token` that Google uses. It's quite simple as it extends the base FOSUserBundle class.

```

// src/Acme/DemoBundle/Entity/User.php

namespace Acme\DemoBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string")
     */
    protected $google_id;

    /**
     * @ORM\Column(type="string")
     */
    protected $google_access_token;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }

    public function getGoogleId()
    {
        return $this->google_id;
    }

    public function setGoogleId($google_id)
    {
        $this->google_id = $google_id;
    }

    public function getGoogleAccessToken()
    {
        return $this->google_access_token;
    }

    public function setGoogleAccessToken($google_access_token)
    {
        $this->google_access_token = $google_access_token;
    }
}

```

Wire the routing
================

[](#wire-the-routing)

Here are the routes that we have to add to `app/config/routing.yml` to have the application be able to login, and register a new user via this bundle. The `google_login` route is used to log a user in (i.e.: it is the entry point for the user). The `google_connect` route is invoked by the Google's OAuth servers to confirm that Google reconizes the user. The `google_after_login`route is invoked when the user has logged in successfully.

```

google_login:
    path:      /google/login
    defaults:  { _controller: MLBOAuthBundle:Google:login }

google_connect:
    path:      /google/connect
    defaults:  { _controller: MLBOAuthBundle:Google:connect }

google_after_login:
    path:      /welcome
    defaults:  { _controller: AcmeDemoBundle:Welcome:index }

```

Gotchas
=======

[](#gotchas)

This is a very preliminary work. It suffers from many missing features, and probably some bugs, too. The most prominent feature missing is the connection of an already existant user to a Google user. Also, other OAuth providers must be added.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0939238c9c2c8f9f240b32ef835b6f925201c735c28807c401921c33e87b1b8e?d=identicon)[marcobuschini](/maintainers/marcobuschini)

---

Top Contributors

[![marcobuschini](https://avatars.githubusercontent.com/u/6851947?v=4)](https://github.com/marcobuschini "marcobuschini (46 commits)")

### Embed Badge

![Health badge](/badges/marcobuschini-o-auth-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/marcobuschini-o-auth-bundle/health.svg)](https://phpackages.com/packages/marcobuschini-o-auth-bundle)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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