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.0.1(1y ago)1969↓100%MITPHPPHP ^8.1

Since Aug 1Pushed 1y 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 1mo ago

READMEChangelogDependencies (8)Versions (15)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

34

—

LowBetter than 77% of packages

Maintenance41

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~86 days

Total

13

Last Release

525d 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://www.gravatar.com/avatar/dd142417560a611ad9091b083d6a5a12bb14c73b1195ca9ff792a447cfcc5694?d=identicon)[srako](/maintainers/srako)

---

Top Contributors

[![srako](https://avatars.githubusercontent.com/u/18043224?v=4)](https://github.com/srako "srako (25 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

[facile-it/php-openid-client

OpenID (OIDC) Client

42592.7k7](/packages/facile-it-php-openid-client)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[simplesamlphp/simplesamlphp-module-oidc

A SimpleSAMLphp module adding support for the OpenID Connect protocol

5016.9k1](/packages/simplesamlphp-simplesamlphp-module-oidc)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)[growthbook/growthbook

PHP SDK for GrowthBook, the feature flagging and A/B testing platform

202.9M3](/packages/growthbook-growthbook)

PHPackages © 2026

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