title: Keycloak with PHP - BASICS
body: <p>I want to use Keycloak as an identity provider (IdP) which secure access to my application written in PHP. Because Keycloak have no supported Client Adapters for PHP, I researched a litte bit. There are different ways to integrate the Relying Party (RP) into client application:</p>
  <ol>
  <li>Keycloak have mod_auth_openidc. So this is a module for a Apache server as Relying Party. (It blocks the request before reaching the service )</li>
  <li>Over things like <a href="https://oauth.net/code/php/" rel="nofollow noreferrer">PHP Clients</a> or Laravel --&gt; <a href="https://github.com/authlete/authlete-php" rel="nofollow noreferrer">Authlete Laravel</a></li>
  </ol>
  <p>I am completely new to this area and prefer number 2,3. I have set up an Keycloak server and wrote a ServiceProviderInterface (SPI) for my User DB in the Keycloak server. This works fine and with Postman I am able to request the endpoints. Next step is to build an example PHP application to secure with Keycloak. Are there any basic step by step tutorials out there?</p>
  <p>How do i authenticate my user against the IdP?
  And how do I authorize later with the scopes and claims of Keycloak?
  And are there any better tutorials out there?
  I found <a href="https://tliebrand.com/18-sicherheit/27-authenticate-keycloak-access-token-in-laravel" rel="nofollow noreferrer">AUTHENTICATE KEYCLOAK ACCESS TOKEN IN LARAVEL</a>, <a href="https://fawnoos.com/2020/12/22/cas63x-oidc-php-client/" rel="nofollow noreferrer">Apereo CAS - Securing PHP with OpenID Connect</a>, <a href="https://github.com/jumbojett/OpenID-Connect-PHP" rel="nofollow noreferrer">PHP OpenID Connect Basic Client</a> but they did not really help me setting things up.</p>