PHPackages                             dcid/server-sdk - 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. dcid/server-sdk

ActiveLibrary

dcid/server-sdk
===============

PHP SDK for the DCID Backend API

01↓100%PHP

Since Apr 6Pushed yesterdayCompare

[ Source](https://github.com/gettrustid/dcid-backend-sdk-php)[ Packagist](https://packagist.org/packages/dcid/server-sdk)[ RSS](/packages/dcid-server-sdk/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

DCID Server SDK for PHP
=======================

[](#dcid-server-sdk-for-php)

PHP SDK for the DCID Backend API. Provides authentication, identity management, encrypted credential storage (IPFS/blob storage), verification, and analytics capabilities.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Composer

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

[](#installation)

```
composer require dcid/server-sdk
```

Quick Start
-----------

[](#quick-start)

```
use DCID\ServerSDK\DCIDServerSDK;
use DCID\ServerSDK\Types\InitiateOTPOptions;
use DCID\ServerSDK\Types\ConfirmOTPOptions;

$sdk = new DCIDServerSDK([
    'apiKey' => 'your-api-key',
    'environment' => 'prod', // or 'dev'
]);

// Step 1: Initiate OTP
$result = $sdk->auth->registerOtp(new InitiateOTPOptions(email: 'user@example.com'));

// Step 2: Confirm OTP (tokens are automatically stored)
$tokens = $sdk->auth->confirmOtp(new ConfirmOTPOptions(
    otp: '123456',
    email: 'user@example.com',
));

// Step 3: Use authenticated endpoints
$key = $sdk->identity->encryption->generateKey(
    new \DCID\ServerSDK\Types\GenerateEncryptionKeyOptions(
        did: 'did:iden3:trustid:main:...',
        ownerEmail: 'user@example.com',
    )
);
```

Configuration
-------------

[](#configuration)

```
$sdk = new DCIDServerSDK([
    'apiKey' => 'your-api-key',          // Required
    'environment' => 'prod',              // 'dev' or 'prod' (default: 'prod')
    'timeout' => 30000,                   // Request timeout in ms (default: 30000)
    'defaultHeaders' => [],               // Custom headers
    'logger' => new ConsoleLogger(),      // Custom logger
    'enableRequestLogging' => false,      // Enable request/response logging
]);
```

Modules
-------

[](#modules)

### Authentication (`$sdk->auth`)

[](#authentication-sdk-auth)

MethodDescription`registerOtp(InitiateOTPOptions)`Initiate OTP registration/sign-in`confirmOtp(ConfirmOTPOptions)`Confirm OTP and receive tokens`adminLogin(InitiateOTPOptions)`Initiate admin login`refreshToken(RefreshTokenOptions)`Refresh access token### Identity - Encryption (`$sdk->identity->encryption`)

[](#identity---encryption-sdk-identity-encryption)

MethodDescription`generateKey(GenerateEncryptionKeyOptions)`Generate encryption key for a DID`getKey(GetEncryptedKeyOptions)`Retrieve encrypted key### Identity - Issuer (`$sdk->identity->issuer`)

[](#identity---issuer-sdk-identity-issuer)

MethodDescription`issueCredential(IssueCredentialOptions)`Issue a verifiable credential`getCredentialOffer(GetCredentialOfferOptions)`Get credential offer status### Identity - Encrypted Storage (`$sdk->identity->ipfs`)

[](#identity---encrypted-storage-sdk-identity-ipfs)

Credential storage backed by IPFS or blob storage. All data is assumed to be pre-encrypted by the client before storage.

MethodDescription`storeCredential(StoreCredentialOptions)`Store an encrypted credential to IPFS/blob storage`retrieveUserCredential(RetrieveUserCredentialOptions)`Retrieve an encrypted credential`getAllUserCredentials(GetAllUserCredentialsOptions)`Get all encrypted credentials for a user### Identity - Verification (`$sdk->identity->verification`)

[](#identity---verification-sdk-identity-verification)

MethodDescription`verifySignIn(VerifySignInOptions)`Initiate sign-in verification`getLinkStore(GetLinkStoreOptions)`Get stored proof request`postLinkStore(PostLinkStoreOptions)`Store proof request`verifyCallback(VerifyCallbackOptions)`Submit and verify proof response### Analytics (`$sdk->analytics`)

[](#analytics-sdk-analytics)

MethodDescription`startSession(?StartSessionEvent)`Start analytics session`endSession(EndSessionEvent)`End analytics sessionError Handling
--------------

[](#error-handling)

```
use DCID\ServerSDK\Errors\AuthenticationError;
use DCID\ServerSDK\Errors\NetworkError;
use DCID\ServerSDK\Errors\ServerError;
use DCID\ServerSDK\Errors\DCIDServerSDKError;

try {
    $result = $sdk->identity->encryption->generateKey($options);
} catch (AuthenticationError $e) {
    if ($e->isApiKeyError) {
        // Invalid API key
    } else {
        // JWT token issue (expired, invalid)
    }
} catch (NetworkError $e) {
    // Connection timeout, DNS failure, etc.
    echo $e->errorCode; // e.g., 'ECONNREFUSED'
} catch (ServerError $e) {
    if ($e->isBackendConnectivityError) {
        // Backend service unreachable (via KrakenD)
    }
} catch (DCIDServerSDKError $e) {
    // Other API errors (4xx)
    echo $e->statusCode;
    echo $e->context?->url;
}
```

Token Management
----------------

[](#token-management)

Tokens are automatically managed after `confirmOtp()` or `refreshToken()`. You can also manage them manually:

```
$sdk->setAuthToken('your-access-token');
$sdk->setRefreshToken('your-refresh-token');

$accessToken = $sdk->getAuthToken();
$refreshToken = $sdk->getRefreshToken();
```

The SDK automatically refreshes expired access tokens on 401 responses.

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance65

Regular maintenance activity

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

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://avatars.githubusercontent.com/u/74903896?v=4)[tracer-labs](/maintainers/tracer-labs)[@tracer-labs](https://github.com/tracer-labs)

### Embed Badge

![Health badge](/badges/dcid-server-sdk/health.svg)

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

PHPackages © 2026

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