PHPackages                             xzawed/keycloak-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xzawed/keycloak-sdk

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

xzawed/keycloak-sdk
===================

Keycloak SDK for PHP — OIDC/OAuth2 authentication + Admin REST API, part of a nine-language polyglot SDK

v0.1.0-rc.1(yesterday)02↑2900%Apache-2.0PHPPHP ^8.3

Since Aug 1Pushed todayCompare

[ Source](https://github.com/xzawed/keycloak-sdk-php)[ Packagist](https://packagist.org/packages/xzawed/keycloak-sdk)[ Docs](https://github.com/xzawed/KeyCloakSDK/tree/main/php#readme)[ RSS](/packages/xzawed-keycloak-sdk/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (15)Versions (2)Used By (0)

Keycloak SDK for PHP
====================

[](#keycloak-sdk-for-php)

An idiomatic PHP SDK for [Keycloak](https://www.keycloak.org/) covering both OIDC/OAuth2 authentication and the Admin REST API behind one consistent facade.

Part of a **nine-language polyglot SDK** (Java · Python · Node · Go · C# · PHP · Rust · Ruby · Kotlin) — one API shape, nine idioms: [github.com/xzawed/KeyCloakSDK](https://github.com/xzawed/KeyCloakSDK).

> **Pre-release** — not yet published to Packagist.

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

[](#requirements)

- PHP **8.3+** (`composer.json` requires `^8.3`)
- Keycloak server 26.6.x (verified by the integration suite)

Install
-------

[](#install)

The SDK is developed in the `php/` directory of a polyglot monorepo, and Packagist cannot install from a subdirectory. Releases are therefore subtree-split into the dedicated read-only repository [`xzawed/keycloak-sdk-php`](https://github.com/xzawed/keycloak-sdk-php), which is what Packagist reads — the package name stays `xzawed/keycloak-sdk`:

```
composer require xzawed/keycloak-sdk
```

```
use Xzawed\Keycloak\{KeycloakClient, KeycloakConfig};   // admin lives under Xzawed\Keycloak\Admin
```

Quickstart
----------

[](#quickstart)

`KeycloakClient::create()` assembles auth immediately (no network); `admin()` is created lazily on first call and needs a client secret. Value types are `final readonly class`, and failures throw the `KeycloakException` hierarchy.

```
