verixo/sdk

Official PHP SDK for the Verixo OTP-as-a-Service API

Maintainers

Package info

github.com/titicodes/verixo-php

Homepage

pkg:composer/verixo/sdk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-06-22 09:53 UTC

This package is auto-updated.

Last update: 2026-06-22 10:12:26 UTC


README

Official PHP SDK for the Verixo OTP-as-a-Service API.

Install

composer require verixo/sdk

Quickstart

use Verixo\Client;

$vc = new Client(getenv('VC_API_KEY'));

$result = $vc->numbers->search([
    'serviceSlug' => 'whatsapp',
    'countryCode' => 'NG',
    'minScore'    => 80,
    'limit'       => 5,
]);

$session = $vc->numbers->purchase([
    'serviceSlug' => 'whatsapp',
    'countryCode' => 'NG',
]);

$vc->subscribe($session->sessionToken, function ($push) {
    echo "OTP: {$push->otp} in {$push->latencyMs}ms\n";
});

Note: purchase() takes serviceSlug + countryCode, not a specific numberId -- the server picks the best available number by Health Score at purchase time, since a candidate returned by search() could already be gone by the time you'd reference it back.

subscribe() is synchronous, unlike the Node/Python SDKs

PHP scripts typically run to completion rather than holding an event loop open, so subscribe() blocks the calling script until the OTP arrives or $timeoutSeconds elapses (default 90s) -- it doesn't return an unsubscribe handle. It returns the OtpPush (also passed to your callback), or null on timeout.

Polling instead of real-time push

$result = $vc->sessions->waitForOtp($session->sessionToken, timeoutSeconds: 90);
if ($result->status === 'DELIVERED') {
    echo $result->otpCode;
}

Errors

All non-2xx responses throw Verixo\Exception\VerixoException with ->status, and usually ->errorCode/->detail from the API's error body:

use Verixo\Exception\VerixoException;

try {
    $vc->numbers->purchase(['serviceSlug' => 'whatsapp', 'countryCode' => 'NG']);
} catch (VerixoException $e) {
    if ($e->status === 402) {
        echo "Insufficient wallet balance\n";
    }
}

Requirements

PHP 8.1+, with the curl and json extensions (both enabled by default in most PHP installs).

Development

composer install
composer exec phpstan analyse   # static analysis, level 8
php examples/quickstart.php     # requires VC_API_KEY env var, see file header