Skip to content

Installation & configuration ​

anikeen/id is the PHP client for the Anikeen ID API, shipped as a Laravel package. It covers OAuth login (a Socialite provider), an API token guard, the billing API and webhook verification.

Requirements: PHP 8.2+, Laravel 12 or 13.

Install ​

shell
composer require anikeen/id

The service provider and the AnikeenId facade are registered automatically.

Configure ​

Register your app first, then add its credentials to .env:

ini
ANIKEEN_ID_KEY=
ANIKEEN_ID_SECRET=
ANIKEEN_ID_CALLBACK_URL=http://localhost/auth/callback
ANIKEEN_ID_WEBHOOK_SECRET=

To switch from production to staging:

ini
ANIKEEN_ID_MODE=staging

Add an entry to config/services.php, so the configuration is still available after php artisan config:cache:

php
'anikeen' => [
    'mode' => env('ANIKEEN_ID_MODE'),
    'client_id' => env('ANIKEEN_ID_KEY'),
    'client_secret' => env('ANIKEEN_ID_SECRET'),
    'redirect' => env('ANIKEEN_ID_CALLBACK_URL'),
    'base_url' => env('ANIKEEN_ID_BASE_URL'),
    'webhook_secret' => env('ANIKEEN_ID_WEBHOOK_SECRET'),
],
Key
modeproduction (default) or staging; picks the base URL and the bundled public key
client_id, client_secretyour OAuth client
redirectyour callback URL (a registered redirect URI)
base_urloverrides the base URL, e.g. for a local Anikeen ID instance
webhook_secretthe signing secret whsec_… of your webhook endpoint

The API token guard has more options under the same key.

The client ​

Anikeen\Id\AnikeenId is the API client, registered as a singleton:

php
$anikeenId = app(\Anikeen\Id\AnikeenId::class);
// or the facade
use Anikeen\Id\Facades\AnikeenId;

Setters and immutable variants:

php
$anikeenId = new Anikeen\Id\AnikeenId();

$anikeenId->setClientId('abc123');
$anikeenId->setClientSecret('abc456');
$anikeenId->setToken('abcdef123456');

$anikeenId = $anikeenId->withClientId('abc123');
$anikeenId = $anikeenId->withClientSecret('abc123');
$anikeenId = $anikeenId->withToken('abcdef123456');

$user = $anikeenId->withToken('uvwxyz456789')->getAuthedUser()->shift();
AnikeenId::withToken('abcdef123456')->getAuthedUser();

Methods of trusted apps (app*(), createChargeForUser(), findUserById(), …) fetch and cache the app's own token (client credentials) themselves; asApp() returns a copy of the client that uses it.

Results and resources ​

Low-level methods on AnikeenId (e.g. getAuthedUser(), createOrderPreview(), refreshToken()) return a Result. Check it before you use it:

php
$result = $anikeenId->getAuthedUser();

if (! $result->success()) {
    die('Ooops: ' . $result->error());
}

$user = $result->shift(); // the object, or the first item of a list

Resource methods ($user->orders(), $anikeenId->sshKeysByUserId(), …) return objects and throw an ApiException instead, see Errors.

Anikeen ID developer documentation