Skip to content

Commit 7d57888

Browse files
committed
feat: add builder
1 parent c76c1c5 commit 7d57888

34 files changed

Lines changed: 496 additions & 150 deletions

.github/workflows/php-analysis.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
name: PHP Analysis
88

99
jobs:
10-
Analyze:
10+
analyze:
11+
name: 🔍 Analyze
1112
runs-on: ubuntu-latest
1213

1314
strategy:
@@ -18,12 +19,16 @@ jobs:
1819
PHP_CS_FIXER_IGNORE_ENV: 1 # Remove when PHP 8.4 is officially supported by PHP CS Fixer
1920

2021
steps:
21-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v5
2223

2324
- uses: shivammathur/setup-php@v2
2425
with:
2526
php-version: ${{ matrix.php }}
2627

28+
- name: Remove roave/backward-compatibility-check for PHP 8.1
29+
if: matrix.php == '8.1'
30+
run: composer remove --dev roave/backward-compatibility-check || true
31+
2732
- name: Install dependencies
2833
run: composer install --prefer-dist --no-progress
2934

@@ -32,3 +37,22 @@ jobs:
3237

3338
- name: Run PHP-CS-Fixer
3439
run: composer cs
40+
41+
bc_check:
42+
name: 🕵🏼 Check Backwards Compatibility
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v5
47+
with:
48+
fetch-depth: 0
49+
50+
- uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: 8.2
53+
54+
- name: Install dependencies
55+
run: composer install --prefer-dist --no-progress
56+
57+
- name: Run BC Check
58+
run: vendor/bin/roave-backward-compatibility-check

.github/workflows/php-integration.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name: PHP Integration (Keycloak compatibility)
99
jobs:
1010
Integration:
1111
runs-on: ubuntu-latest
12+
name: 🧩 Integration Tests
1213

1314
strategy:
1415
matrix:
@@ -21,7 +22,7 @@ jobs:
2122
XDEBUG_MODE: coverage
2223

2324
steps:
24-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
2526

2627
- uses: shivammathur/setup-php@v2
2728
with:

.github/workflows/php-unit.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name: PHP Unit
99
jobs:
1010
Unit:
1111
runs-on: ubuntu-latest
12+
name: ⚙️ Unit Tests
1213
env:
1314
XDEBUG_MODE: coverage
1415

@@ -17,7 +18,7 @@ jobs:
1718
php: [ 8.1, 8.2, 8.3, 8.4 ]
1819

1920
steps:
20-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2122

2223
- uses: shivammathur/setup-php@v2
2324
with:
@@ -31,7 +32,7 @@ jobs:
3132
run: vendor/bin/phpunit --testsuite unit
3233

3334
- name: Upload coverage reports
34-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3536
with:
3637
fail_ci_if_error: true
3738
files: phpunit.cobertura.xml

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ composer require fschmtt/keycloak-rest-api-client-php
2222
Example:
2323

2424
```php
25-
$keycloak = new \Fschmtt\Keycloak\Keycloak(
26-
baseUrl: 'http://keycloak:8080',
27-
username: 'admin',
28-
password: 'admin',
29-
realm: 'master'
25+
$keycloak = (new \Fschmtt\Keycloak\Builder())
26+
->withBaseUrl('http://keycloak:8080')
27+
->withGrantType(\Fschmtt\Keycloak\OAuth\GrantType::password('admin', 'admin'))
28+
->build();
3029
);
3130

3231
$serverInfo = $keycloak->serverInfo()->get();

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"ramsey/uuid": "^4.7",
1717
"phpunit/phpunit": "^10",
1818
"phpstan/phpstan-deprecation-rules": "^2.0",
19-
"vimeo/psalm": "^0.3.14",
20-
"friendsofphp/php-cs-fixer": "^3.65"
19+
"friendsofphp/php-cs-fixer": "^3.65",
20+
"roave/backward-compatibility-check": "^8.14"
2121
},
2222
"autoload": {
2323
"psr-4": {

examples/attack-detection-clear-user.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Fschmtt\Keycloak\Keycloak;
5+
use Fschmtt\Keycloak\Builder;
6+
use Fschmtt\Keycloak\OAuth\GrantType;
67

78
require_once __DIR__ . '/../vendor/autoload.php';
89

9-
$keycloak = new Keycloak(
10-
$_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
11-
'admin',
12-
'admin',
13-
);
10+
$keycloak = (new Builder())
11+
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
12+
->withGrantType(GrantType::password('admin', 'admin'))
13+
->build();
1414

1515
$keycloak->attackDetection()->clearUser(
1616
realm: 'master',

examples/attack-detection-clear.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Fschmtt\Keycloak\Keycloak;
5+
use Fschmtt\Keycloak\Builder;
6+
use Fschmtt\Keycloak\OAuth\GrantType;
67

78
require_once __DIR__ . '/../vendor/autoload.php';
89

9-
$keycloak = new Keycloak(
10-
$_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
11-
'admin',
12-
'admin',
13-
);
10+
$keycloak = (new Builder())
11+
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
12+
->withGrantType(GrantType::password('admin', 'admin'))
13+
->build();
1414

1515
$keycloak->attackDetection()->clear(
1616
realm: 'master',

examples/attack-detection-user-status.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Fschmtt\Keycloak\Keycloak;
5+
use Fschmtt\Keycloak\Builder;
6+
use Fschmtt\Keycloak\OAuth\GrantType;
67

78
require_once __DIR__ . '/../vendor/autoload.php';
89

9-
$keycloak = new Keycloak(
10-
$_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
11-
'admin',
12-
'admin',
13-
);
10+
$keycloak = (new Builder())
11+
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
12+
->withGrantType(GrantType::password('admin', 'admin'))
13+
->build();
1414

1515
$userStatus = $keycloak->attackDetection()->userStatus(
1616
realm: 'master',

examples/clients-all.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Fschmtt\Keycloak\Keycloak;
5+
use Fschmtt\Keycloak\Builder;
6+
use Fschmtt\Keycloak\OAuth\GrantType;
67

78
require_once __DIR__ . '/../vendor/autoload.php';
89

9-
$keycloak = new Keycloak(
10-
baseUrl: $_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
11-
username: 'admin',
12-
password: 'admin',
13-
);
10+
$keycloak = (new Builder())
11+
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
12+
->withGrantType(GrantType::password('admin', 'admin'))
13+
->build();
1414

1515
$realm = $keycloak->realms()->get('master');
1616

examples/clients-get.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Fschmtt\Keycloak\Keycloak;
5+
use Fschmtt\Keycloak\Builder;
6+
use Fschmtt\Keycloak\OAuth\GrantType;
67

78
require_once __DIR__ . '/../vendor/autoload.php';
89

9-
$keycloak = new Keycloak(
10-
baseUrl: $_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
11-
username: 'admin',
12-
password: 'admin',
13-
);
10+
$keycloak = (new Builder())
11+
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
12+
->withGrantType(GrantType::password('admin', 'admin'))
13+
->build();
1414

1515
$resource = $keycloak->clients();
1616
$clients = $keycloak->clients()->all(realm: 'master');

0 commit comments

Comments
 (0)