1. Go to this page and download the library: Download curentis/openfga-php 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/ */
use Curentis\OpenFga\Credentials\ApiToken;
use Curentis\OpenFga\Credentials\ClientCredentials;
// Bearer API token (hosted OpenFGA)
new ClientConfiguration(credentials: new ApiToken($apiToken));
// OAuth2 client credentials
new ClientConfiguration(credentials: new ClientCredentials(
clientId: '...',
clientSecret: '...',
apiTokenIssuer: 'https://auth.example.com',
apiAudience: 'https://api.us1.fga.dev/',
));
$fga = OpenFgaClientFactory::create(new ClientConfiguration(
componentFactory: new MyComponentFactory(),
));