PHPackages                             symfonycorp/connect - 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. symfonycorp/connect

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

symfonycorp/connect
===================

SymfonyConnect SDK

v8.2.2(5mo ago)9245.2k↓36.7%332MITPHPPHP &gt;=8.0.2

Since Feb 15Pushed 5mo ago17 watchersCompare

[ Source](https://github.com/symfonycorp/connect)[ Packagist](https://packagist.org/packages/symfonycorp/connect)[ Docs](https://github.com/symfonycorp/connect)[ Fund](https://tidelift.com/funding/github/packagist/symfonycorp/connect)[ RSS](/packages/symfonycorp-connect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (84)Used By (2)

SymfonyConnect SDK
==================

[](#symfonyconnect-sdk)

About
-----

[](#about)

This is the official SDK for the SymfonyConnect API. It works for the public API or with a registered OAuth application. To register an application, please go to your [SymfonyConnect Account](https://connect.symfony.com).

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

[](#installation)

To install the SDK, run the command below and you will get the latest version:

```
composer require symfonycorp/connect
```

Usage
-----

[](#usage)

### OAuth

[](#oauth)

To use the SDK in a Symfony application, we recommend using the built-in bundle.

Otherwise, you can take inspiration from the following part, which will show you how to include OAuth authentication within a Silex App.

Warning: We take for granted that you already have registered your app on [SymfonyConnect](https://connect.symfony.com) and that you're in possession of your `application_id`, `application_secret` and `scope`.

1. Configure your silex app with the data we gave us at app registration.

    ```
    // index.php
    use SymfonyCorp\Connect\Api\Api;
    use SymfonyCorp\Connect\OAuthConsumer;

    $app = new Silex\Application();
    $app['connect_id'] = 'application_id';
    $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
    $app->register(new Silex\Provider\SessionServiceProvider());

    $app['connect_secret'] = 'application_secret';
    // List of scope copy-pasted from your application page on SymfonyConnect
    $app['connect_scope'] = array(
        'SCOPE_ADDITIONAL_EMAILS',
        'SCOPE_BIRTHDAY',
        'SCOPE_EMAIL',
        'SCOPE_LOCATION',
        'SCOPE_PUBLIC',
        'SCOPE_SSH_KEYS',
    );

    $app['connect_consumer'] = new OAuthConsumer(
        $app['connect_id'],
        $app['connect_secret'],
        implode(' ', $app['connect_scope']) // scope MUST be space separated
    );
    $app['connect_api'] = new Api();
    ```

    This done. We can now move on to the second step.
2. We need to create two controllers to handle the OAuth2 Three-Legged workflow.

    The first controller goal is to redirect the user to SymfonyConnect in order to ask him for the authorization that your app will use his data. This controller will be bound to the `connect_auth` route. In your template, you'll need to create a link to this route.

    ```
    // index.php
    $app->get('/connect/new', function () use ($app) {
        $callback = $app['url_generator']->generate('connect_callback', array(), true);
        $url = $app['connect_consumer']->getAuthorizationUri($callback);

        return $app->redirect($url);
    })->bind('connect_auth');
    ```

    The second controller is the one that will welcome the user after SymfonyConnect redirected him to your application. When registering your client, you'll have to provide the exact absolute URL that points to this controller.

    ```
    $app->get('/connect/callback', function (Request $request) use ($app) {
        // There was an error during the workflow.
        if ($request->get('error')) {
            throw new \RuntimeException($request->get('error_description'));
        }

        // Everything went fine, you can now request an access token.
        try {
            $data = $app['connect_consumer']->requestAccessToken($app['url_generator']->generate('connect_callback', array(), true), $request->get('code'));
        } catch (OAuthException $e) {
            throw $e;
        }

        // At this point, we have an access token and we can use the SDK to request the API
        $app['connect_api']->setAccessToken($data['access_token']); // All further request will be done with this access token
        $root = $app['connect_api']->getRoot();
        $user = $root->getCurrentUser();
        $user->getBadges()->refresh();

        $app['session']->start();
        $app['session']->set('connect_access_token', $data['access_token']);
        $app['session']->set('connect_user', $user);

        return $app->redirect('/');
    })->bind('connect_callback');
    ```
3. Create a link from your template

    In a template, you can use the following snippet of code to render a SymfonyConnect button:

    ```

        Log in with SymfonyConnect

    ```

    And include the following CSS file: `https://connect.symfony.com/css/sln.css`

Et voilà! Your application can now use SymfonyConnect as an authentication method!

### The API

[](#the-api)

The SymfonyConnect Connect API is RESTFul and (tries to) conforms to the HATEOAS principle.

Here are some useful recipes.

1. Search

    ```
    $root = $api->getRoot();

    // Will search for users
    $users = $root->getUsers('fab');
    ```
2. Edit authenticated user

    ```
    $app['connect_api']->setAccessToken($app['session']->get('connect_access_token'));
    $root = $app['connect_api']->getRoot();
    $user = $root->getCurrentUser();
    $user->setBiography("I'm sexy and I know it.");
    $user->submitForm();
    ```

As you can see by these examples, you always have to to go through the API Root to make an action. This is because the API is discoverable and that the SDK should not know anything beside the API's entry point.

License
-------

[](#license)

This library is licensed under the MIT license.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance72

Regular maintenance activity

Popularity45

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~58 days

Total

81

Last Release

158d ago

Major Versions

v5.1.5 → v6.0.02019-07-26

4.3.x-dev → v6.2.02020-06-14

v6.3.0 → v7.0.02020-08-07

v5.1.6 → v7.2.12021-02-10

v7.4.0 → v8.0.02022-05-16

PHP version history (5 changes)v4.3.0PHP &gt;=5.5.9

v5.1.0PHP ^7.1.3

v6.0.0PHP &gt;=7.1.3

v7.2.1PHP &gt;=7.2.4

v8.0.0PHP &gt;=8.0.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47313?v=4)[Fabien Potencier](/maintainers/fabpot)[@fabpot](https://github.com/fabpot)

---

Top Contributors

[![fabpot](https://avatars.githubusercontent.com/u/47313?v=4)](https://github.com/fabpot "fabpot (83 commits)")[![lyrixx](https://avatars.githubusercontent.com/u/408368?v=4)](https://github.com/lyrixx "lyrixx (74 commits)")[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (45 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (32 commits)")[![tucksaun](https://avatars.githubusercontent.com/u/870118?v=4)](https://github.com/tucksaun "tucksaun (10 commits)")[![marcw](https://avatars.githubusercontent.com/u/160332?v=4)](https://github.com/marcw "marcw (9 commits)")[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (8 commits)")[![ruian](https://avatars.githubusercontent.com/u/564529?v=4)](https://github.com/ruian "ruian (6 commits)")[![JJarrie](https://avatars.githubusercontent.com/u/10710580?v=4)](https://github.com/JJarrie "JJarrie (3 commits)")[![inelgnu](https://avatars.githubusercontent.com/u/665908?v=4)](https://github.com/inelgnu "inelgnu (3 commits)")[![romainneutron](https://avatars.githubusercontent.com/u/137574?v=4)](https://github.com/romainneutron "romainneutron (3 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (2 commits)")[![lucasaba](https://avatars.githubusercontent.com/u/206325?v=4)](https://github.com/lucasaba "lucasaba (2 commits)")[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (1 commits)")[![iamluc](https://avatars.githubusercontent.com/u/1539731?v=4)](https://github.com/iamluc "iamluc (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![pgrimaud](https://avatars.githubusercontent.com/u/1866496?v=4)](https://github.com/pgrimaud "pgrimaud (1 commits)")[![qdequippe](https://avatars.githubusercontent.com/u/3193300?v=4)](https://github.com/qdequippe "qdequippe (1 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (1 commits)")[![gido](https://avatars.githubusercontent.com/u/101859?v=4)](https://github.com/gido "gido (1 commits)")

---

Tags

authenticationconnectoauthphpsdksymfonysdkSymfonyConnect

### Embed Badge

![Health badge](/badges/symfonycorp-connect/health.svg)

```
[![Health](https://phpackages.com/badges/symfonycorp-connect/health.svg)](https://phpackages.com/packages/symfonycorp-connect)
```

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[happyr/linkedin-api-client

LinkedIn API client. Handles OAuth, CSRF protection. Easy to implement and extend. This is a standalone library for any composer project.

1991.6M12](/packages/happyr-linkedin-api-client)[surfoo/geocaching-php-sdk

Geocaching PHP SDK

143.4k1](/packages/surfoo-geocaching-php-sdk)

PHPackages © 2026

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