PHP code example of haizad / laravel-keycloak-admin

1. Go to this page and download the library: Download haizad/laravel-keycloak-admin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

haizad / laravel-keycloak-admin example snippets



//"Register Service Providers"  section
$app->register(\LaravelKeycloakAdmin\KeycloakAdminServiceProvider::class);
$app->configure('keycloakAdmin');

$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    

KeycloakAdmin::serviceName()->apiName($parameters)

//Create User Sample
//Refer https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_userrepresentation
KeycloakAdmin::user()->create([
                'body' => [
                        'username' => 'foo',
                        'enabled' => true,
                        'emailVerified' => false,
                        'email' => '[email protected]',
                        'credentials' => [[
                            'type' => 'password',
                            'value' => 'foobar',
                            'temporary' => false
                        ]]
                  ]
]);

//Query User Sample
//Refer Query parameter on GET /{realm}/users https://www.keycloak.org/docs-api/11.0/rest-api/index.html
KeycloakAdmin::user()->find([
            'query' => [ 
                 'email' => '[email protected]'
            ]
]);

//Get All User Sample
KeycloakAdmin::user()->all();

shell
php artisan vendor:publish --provider="LaravelKeycloakAdmin\KeycloakAdminServiceProvider"
keycloakAdmin.php
bootstrap/app.php
bootstrap/app.php
config\keycloakAdmin.php