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

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

srako/openid-connect
====================

PHP implementation of https://openid.net/specs/openid-connect-core-1\_0.html

v2.1.0(3mo ago)11.1kMITPHPPHP ^8.1

Since Aug 1Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/srako/openid-connect)[ Packagist](https://packagist.org/packages/srako/openid-connect)[ Docs](https://github.com/srako/openid-connect)[ RSS](/packages/srako-openid-connect/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (16)Versions (16)Used By (0)

OIDC Connect
============

[](#oidc-connect)

PHP implementation of [https://openid.net/specs/openid-connect-core-1\_0.html](https://openid.net/specs/openid-connect-core-1_0.html)

Install
-------

[](#install)

Via [Composer](https://getcomposer.org/)

```
$ composer require srako/openid-connect
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

#### Using the OIDC discovery endpoint

[](#using-the-oidc-discovery-endpoint)

```
use Srako\OpenIDConnect\ClientMetadata;
use Srako\OpenIDConnect\ClientFactory;

$issuerUrl = 'https://example.com';
$clientMetadata = new ClientMetadata('clientid', 'clientsecret', 'https://example.com/callback');
$client = ClientFactory::create($issuerUrl, $clientMetadata);
```

Manually```
use Srako\OpenIDConnect\Client;
use Srako\OpenIDConnect\ClientMetadata;
use Srako\OpenIDConnect\Config;
use Srako\OpenIDConnect\Http\HttpClientFactory;
use Srako\OpenIDConnect\Token\TokenVerifierFactory;
use Srako\OpenIDConnect\ProviderMetadata;

$clientMetadata = new ClientMetadata('clientid', 'clientsecret', 'https://example.com/callback');
$providerMetadata = new ProviderMetadata([
    ProviderMetadata::AUTHORIZATION_ENDPOINT => 'https://example.com/authorize',
    ProviderMetadata::TOKEN_ENDPOINT => 'https://example.com/token',
    // ...
])
$config = new Config($providerMetadata, $clientMetadata);
$client = new Client($config, HttpClientFactory::create());
```

### Authorization Code flow

[](#authorization-code-flow)

#### Step 1 - Redirect the user to authorization endpoint

[](#step-1---redirect-the-user-to-authorization-endpoint)

```
use Srako\OpenIDConnect\Param\AuthorizationParams;

$state = bin2hex(random_bytes(8));
$_SESSION['oauth_state'] = $state;

$authorizationParams = new AuthorizationParams([
    AuthorizationParams::SCOPE => 'openid profile',
    AuthorizationParams::STATE => $state,
]);

$url = $client->getAuthorizationUrl($authorizationParams);
header('Location: ' . $url);
exit();
```

#### Step 2 - Handle callback and exchange code for tokens

[](#step-2---handle-callback-and-exchange-code-for-tokens)

```
use Srako\OpenIDConnect\Param\CallbackParams;
use Srako\OpenIDConnect\Param\CallbackChecks;

$tokens = $client->handleCallback(
    new CallbackParams($_GET),
    new CallbackChecks($_SESSION['oauth_state'])
);
```

### Client Credentials flow

[](#client-credentials-flow)

```
use Srako\OpenIDConnect\Grant\ClientCredentials;
use Srako\OpenIDConnect\Param\TokenParams;

$tokens = $client->requestTokens(
    new TokenParams(
        new ClientCredentials(),
        [
            TokenParams::SCOPE => 'some scope'
        ]
    )
);
```

See [examples](examples) for more

Credits
-------

[](#credits)

- [Digital Solutions s.r.o.](https://github.com/srako)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance82

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~190 days

Total

14

Last Release

90d ago

Major Versions

v0.2 → v1.02023-08-08

v1.7 → v2.02024-11-29

v1.7.1 → v2.0.12024-11-29

PHP version history (3 changes)v0.1PHP ^7.4

v1.2PHP ^7.4||^8.0

v2.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18043224?v=4)[srako](/maintainers/srako)[@srako](https://github.com/srako)

---

Top Contributors

[![srako](https://avatars.githubusercontent.com/u/18043224?v=4)](https://github.com/srako "srako (26 commits)")

---

Tags

phpOpenIdOpenID Connectoidc

### Embed Badge

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

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

###  Alternatives

[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36826.2k2](/packages/telnyx-telnyx-php)[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.8k](/packages/cakephp-cakephp)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k19](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

9082.3k](/packages/n1ebieski-ksef-php-client)

PHPackages © 2026

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