PHPackages                             saifulferoz/keycloak-admin-client - 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. saifulferoz/keycloak-admin-client

ActiveLibrary

saifulferoz/keycloak-admin-client
=================================

Enterprise-grade standalone PHP client for Keycloak Admin REST API

v1.0.2(yesterday)012↑2650%MITPHPPHP &gt;=8.2CI failing

Since Aug 28Pushed yesterdayCompare

[ Source](https://github.com/saifulferoz/keycloak-admin-client)[ Packagist](https://packagist.org/packages/saifulferoz/keycloak-admin-client)[ RSS](/packages/saifulferoz-keycloak-admin-client/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (4)Used By (0)

Keycloak Admin PHP Client
=========================

[](#keycloak-admin-php-client)

Enterprise-grade, PSR-compliant, standalone PHP client for Keycloak Admin REST API.

[![PHP Version](https://camo.githubusercontent.com/0be43eddd7df02c94a0fbc04aaa13d5250351c44ab63a3782498d66280b1767a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Features
--------

[](#features)

- **PHP 8.2+ Typed &amp; Immutable**: Readonly properties, backed enums, strict types.
- **Standards Compliant**: Built on PHP-FIG standards (PSR-7, PSR-17, PSR-18 HTTP client, PSR-6/16 cache, PSR-3 logging).
- **Proactive OAuth2 Token Lifecycle**: Automatic token negotiation, proactive renewal before expiration, and token storage caching.
- **Rich Domain Model &amp; Fluent Query Builders**: Complete DTO coverage with helper methods, query builders with pagination, exact matching, and attribute filtering.
- **Domain Exceptions**: Maps HTTP status codes to explicit exceptions (`UserAlreadyExistsException`, `UserNotFoundException`, `RealmNotFoundException`, etc.).
- **Comprehensive Resource Coverage**:
    - **Realms**: CRUD, clear user/realm/keys cache.
    - **Users**: CRUD, search, password reset, send verification/action emails, session logout, realm &amp; client role assignments, group memberships.
    - **Groups**: CRUD, hierarchy / child groups, members, role assignments.
    - **Roles**: Realm roles &amp; client roles CRUD, composite roles, user mappings.
    - **Clients**: CRUD, service account users, client secret regeneration.
    - **Identity Providers**: Instances CRUD.
    - **Attack Detection &amp; Sessions**: Brute-force status check/clearing, session invalidation.

---

Complete User Manual &amp; Use Case Guide
-----------------------------------------

[](#complete-user-manual--use-case-guide)

For exhaustive examples, request payloads, query builder options, and domain exception patterns for every single Keycloak endpoint, read the **[Complete User Manual (USER\_MANUAL.md)](./USER_MANUAL.md)**.

---

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

[](#installation)

```
composer require saifulferoz/keycloak-admin-client
```

---

Quickstart
----------

[](#quickstart)

```
use Feroz\KeycloakAdmin\KeycloakClient;
use Feroz\KeycloakAdmin\Model\User\UserRepresentation;
use Feroz\KeycloakAdmin\Query\UserQuery;

// 1. Instantiate client using the fluent builder
$client = KeycloakClient::builder()
    ->withBaseUrl('https://iam.example.com')
    ->withAuthRealm('master')
    ->withDefaultTargetRealm('mycompany')
    ->withClientCredentials('admin-cli', 'your-client-secret')
    ->build();

// 2. Manage Users
$users = $client->users(); // uses default target realm 'mycompany'

// Create a new user
$newUser = UserRepresentation::create('john.doe@example.com', 'johndoe')
    ->withName('John', 'Doe')
    ->withEmailVerified(true)
    ->withAttribute('department', 'Engineering')
    ->withPassword('TemporaryP@ssword123!', temporary: true);

$userId = $users->create($newUser);

// Query users with pagination and search
$query = UserQuery::create()
    ->withSearch('john')
    ->withEnabled(true)
    ->withPagination(page: 1, perPage: 20);

$results = $users->list($query);
foreach ($results as $user) {
    echo $user->username . ' (' . $user->email . ')' . PHP_EOL;
}

// Reset password
$users->resetPassword($userId, 'NewSecretPassword123!');

// 3. Manage Roles & Groups
$client->users()->addRealmRoleMappings($userId, [
    $client->roles()->getRealmRole('admin')
]);
```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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 ~0 days

Total

3

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42f7ccbb50ac26336f56240519756fffae416abcdc6ff44540947bd2cc941487?d=identicon)[saifulferoz](/maintainers/saifulferoz)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/saifulferoz-keycloak-admin-client/health.svg)

```
[![Health](https://phpackages.com/badges/saifulferoz-keycloak-admin-client/health.svg)](https://phpackages.com/packages/saifulferoz-keycloak-admin-client)
```

###  Alternatives

[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.9k](/packages/cakephp-cakephp)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M687](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[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)

PHPackages © 2026

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