PHPackages                             gap/open-server - 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. gap/open-server

ActiveLibrary

gap/open-server
===============

Gap Open Server

v2.1.0(7y ago)0381PHP

Since Apr 22Pushed 7y ago2 watchersCompare

[ Source](https://github.com/gaptree/gap-php-open-server)[ Packagist](https://packagist.org/packages/gap/open-server)[ Docs](https://github.com/gaptree/gap-php-open-server)[ RSS](/packages/gap-open-server/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (8)Versions (20)Used By (1)

Gap Open Server
===============

[](#gap-open-server)

Install
-------

[](#install)

```
$ composer require gap/open-server

```

API
---

[](#api)

Gap\\Open\\Server\\OpenServer

- \_\_construct(array $opts = \[\])
- authCodeGrant(): Grant\\AuthCodeGrant
- openIdGrant(): Grant\\OpenIdGrant
- clientCdGrant(): Grant\\ClientCdGrant
- appService(): Service\\AppService
- accessTokenService(): Service\\AccessTokenService

Gap\\Open\\Server\\Grant\\AuthCodeGrant

- authCode(string $appId, string $userId, string $redirectUrl, string $scope = ''): ?AuthCodeDto
- accessToken($appId, $code): ?AccessTokenDto

Gap\\Open\\Server\\Grant\\ClientCdGrant

- accessToken(string $appId, string $appSecret): ?AccessTokenDto

Gap\\Open\\Server\\Grant\\OpenIdGrant

- idToken(string $userId) // todo
- accessToken(string $appId, string $token): ?AccessTokenDto

Gap\\Open\\Server\\Service\\AppService

- fetch(string $appId): ?AppDto
- create(AppDto $app): void
- disable(AppDto $app): void

Gap\\Open\\Server\\Service\\AccessTokenService

- bearerAuthorize(string $bearerToken): bool
- extractToken(string $query): string
- fetch(string $token): AccessTokenDto

Usage
-----

[](#usage)

### Auth Code

[](#auth-code)

```
$cnn = new Cnn($pdo, $serverId);
$openServer = new OpenServer(['cnn' => $cnn]);
$authCodeGrant = $openServer->authCodeGrant();

$appId = 'fake-app-id';
$userId = 'fake-user-id';
$redirectUrl = 'fake-redirect-url';
$scope = '';

$authCode = $authCodeGrant->authCode(
    $appId,
    $userId,
    $redirectUrl,
    $scope
);

$accessToken = $authCodeGrant->accessToken(
    $appId,
    $authCode->code
);

if (is_null($accessToken)) {
    return;
}
```

### Client Credentials

[](#client-credentials)

```
$clientCdGrant = $openServer->clientCdGrant();
$appId = 'fake-app-id';
$appSecret = 'fake-app-secret';
$accessToken = $clientCdGrant->accessToken(
    $appId,
    $appSecret
);
```

### OpenId

[](#openid)

```
$publicKey =
    '-----BEGIN PUBLIC KEY-----' . "\n"
    . 'xxx'
    . 'xxx' . "\n"
    . '-----END PUBLIC KEY-----';
$privateKey =
    '------BEGIN RSA PRIVATE KEY----' . "\n"
    . 'xxxx'
    . 'xxx' . "\n"
    . '------END RSA PRIVATE KEY----';

$openServer = new OpenServer([
    'cnn' => $cnn,
    'cache' => $cache,
    'publicKey' => $publicKey,
    'privateKey' => $privateKey
]);

$openIdGrant = $openServer->openIdGrant();

$idToken = $openIdGrant->idToken($userId);
$tokenStr = (string) $idToken;
$accessToken = $openIdGrant->accessToken($appId, $tokenStr);
```

### Authorization

[](#authorization)

```
$token = 'Bearer xxxxx';
$openServer->accessTokenService()
    ->bearerAuthorize($token)
```

Database Schema
---------------

[](#database-schema)

```
CREATE TABLE `open_access_token` (
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `appId` varbinary(64) NOT NULL,
  `userId` varbinary(64) NOT NULL,
  `refresh` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `scope` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  `diff` int(10) unsigned NOT NULL DEFAULT 0,
  `info` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created` datetime NOT NULL,
  `expired` datetime NOT NULL,
  PRIMARY KEY (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `open_app` (
  `appId` varbinary(64) NOT NULL,
  `appSecret` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `appCode` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `appName` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `redirectUrl` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  `privilege` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `scope` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `created` datetime NOT NULL,
  `changed` datetime NOT NULL,
  PRIMARY KEY (`appId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `open_auth_code` (
  `code` varbinary(64) NOT NULL DEFAULT '',
  `appId` varbinary(64) NOT NULL DEFAULT '',
  `userId` varbinary(64) NOT NULL DEFAULT '',
  `redirectUrl` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `scope` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `status` enum('ok','destroyed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'ok',
  `created` datetime NOT NULL,
  `expired` datetime NOT NULL,
  PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `open_refresh_token` (
  `refresh` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `appId` varbinary(64) NOT NULL DEFAULT '',
  `userId` varbinary(64) NOT NULL DEFAULT '',
  `scope` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `created` datetime NOT NULL,
  `expired` datetime NOT NULL,
  PRIMARY KEY (`refresh`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `open_user` (
  `userId` varbinary(64) NOT NULL DEFAULT '',
  `nick` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `zcode` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `avt` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `logined` datetime NOT NULL,
  `created` datetime NOT NULL,
  `changed` datetime NOT NULL,
  PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% 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 ~3 days

Total

19

Last Release

2886d ago

Major Versions

v1.0.8 → v2.0.02018-05-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/29f4e5e2ebe9b4c1482a439ebeed267b98c555501a69ac4fd33845522b068ef9?d=identicon)[zhanjh](/maintainers/zhanjh)

---

Top Contributors

[![zhanjh](https://avatars.githubusercontent.com/u/10229945?v=4)](https://github.com/zhanjh "zhanjh (22 commits)")[![wwq666](https://avatars.githubusercontent.com/u/19240217?v=4)](https://github.com/wwq666 "wwq666 (2 commits)")

---

Tags

gap

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gap-open-server/health.svg)

```
[![Health](https://phpackages.com/badges/gap-open-server/health.svg)](https://phpackages.com/packages/gap-open-server)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[simplesamlphp/simplesamlphp-module-oidc

A SimpleSAMLphp module adding support for the OpenID Connect protocol

5016.9k1](/packages/simplesamlphp-simplesamlphp-module-oidc)[shopware/app-php-sdk

Shopware App SDK for PHP

1577.8k1](/packages/shopware-app-php-sdk)

PHPackages © 2026

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