PHPackages                             alma-medical/keycloak-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. [API Development](/categories/api)
4. /
5. alma-medical/keycloak-client

ActiveLibrary[API Development](/categories/api)

alma-medical/keycloak-client
============================

A PHP client for Keycloak REST API

v1.0.8(6y ago)45.1k↓100%2[2 PRs](https://github.com/alma-medical/keycloak-php-client/pulls)PHP

Since Dec 5Pushed 3y ago2 watchersCompare

[ Source](https://github.com/alma-medical/keycloak-php-client)[ Packagist](https://packagist.org/packages/alma-medical/keycloak-client)[ RSS](/packages/alma-medical-keycloak-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (9)Used By (0)

Keycloak REST API PHP client
============================

[](#keycloak-rest-api-php-client)

This package provides a PHP wrapper for [Keycloak REST API](https://www.keycloak.org/docs-api/5.0/rest-api/).

- [Keycloak REST API PHP client](#keycloak-rest-api-php-client)
    - [Installation](#installation)
    - [How to use it](#how-to-use-it)
        - [Get users](#get-users)
        - [Get user](#get-user)
    - [Cache](#cache)
    - [Running tests](#running-tests)

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

[](#installation)

Run this command to integrate the Keycloak REST API client to your existing project:
`composer require alma-medical/keycloak-client`

How to use it
-------------

[](#how-to-use-it)

First of all we need to configure a oauth2 provider for authenticating against Keycloak. For that purpose we use the [stevenmaguire/oauth2-keycloak](https://github.com/stevenmaguire/oauth2-keycloak) package, a [league/oauth2-client](https://github.com/thephpleague/oauth2-client) Keycloak provider. This is an example of how to do that:

```
use Stevenmaguire\OAuth2\Client\Provider\Keycloak as KeycloakProvider;

$provider = new KeycloakProvider([
    'authServerUrl' => 'https://my-keycloak.com/auth',
    'clientId' => 'myClientId',
    'clientSecret' => 'myCleintSecret',
    'realm' => 'myRealm',
]);
```

Once we have our provider instance we need to create an API client:

```
use AlmaMedical\KeycloakClient\Keycloak;

$client = new Keycloak($provider);
```

Now we can call any api method with `callMedthod()` function:

```
$response = $client->callMethod('users');
```

To make easier the parse of the responses, some methods have been implemented:

### Get users

[](#get-users)

This method gets all the users:

```
use AlmaMedical\KeycloakClient\Method\GetUsers;

$getUsers = new GetUsers($client);
$users = $getUsers->call();
```

### Get user

[](#get-user)

This method get a user

```
use AlmaMedical\KeycloakClient\Method\GetUser;

$getUsers = new GetUser($client, 'user_id');
$user = $getUsers->call();
```

Cache
-----

[](#cache)

You can use a `Psr\Cache\CacheItemPoolInterface` to cache Keycloak tokens. To use it simply set your `CacheItemPoolInterface` and the client will package will use it:

```
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$client->setCachePool(new FilesystemAdapter());
```

Running tests
-------------

[](#running-tests)

To run the tests run the following command:
`./vendor/bin/phpunit`

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

6

Last Release

2315d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea10905dbf570482829755d4f04c5d7ecd259820f8d79e0cb9cdfe9c46bff74c?d=identicon)[alma-medical](/maintainers/alma-medical)

---

Top Contributors

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

---

Tags

apiclientkeycloak

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alma-medical-keycloak-client/health.svg)

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

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[openai-php/symfony

Symfony Bundle for OpenAI

215715.5k3](/packages/openai-php-symfony)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[smnandre/pagespeed-api

PageSpeed Insight PHP Api Client 🚀 Analyse web pages for performances metrics, core web vitals...

1511.5k](/packages/smnandre-pagespeed-api)[optiosteam/payconiq-client-php

Payconiq API client library for PHP developed by Optios.

1273.4k](/packages/optiosteam-payconiq-client-php)[google-gemini-php/symfony

Symfony Bundle for Gemini

149.4k1](/packages/google-gemini-php-symfony)

PHPackages © 2026

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