verifence / verifence-php
Official PHP SDK for Verifence — the pre-send firewall for SMS verification.
v0.1.0
2026-07-25 03:18 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-20 02:38:26 UTC
README
Official PHP client for Verifence — the pre-send firewall for SMS verification.
composer require verifence/verifence-php
Your API key is a secret. Every call is server-to-server. Read the key from an environment variable; never ship it in browser or mobile code.
Usage
use Verifence\Client; use Verifence\QuotaExceededException; $vf = new Client(getenv('VERIFENCE_KEY')); // Before you hand a message to Twilio/Vonage/etc: $verdict = $vf->check( phone: '+14155552671', clientIp: $request->ip(), // the END USER's IP, from your inbound request userId: 'u_123', ); if (! $verdict['allow']) { // Do not send — you just saved the message fee. return response()->json(['error' => 'too_many_verification_requests'], 429); } // ... send the SMS with your provider ... // After the user enters the correct code: $vf->confirm(clientIp: $request->ip());
Handle a spent quota:
try { $verdict = $vf->check('+14155552671', $ip); } catch (QuotaExceededException $e) { // $e->resetsAt() → ISO-8601 reset time }
API
| Method | Returns |
|---|---|
check(string $phone, string $clientIp, ?string $userId = null, bool $requireMobile = false): array |
['allow' => bool, 'reason' => ?string, 'detail' => string, 'degraded' => bool, ...] |
confirm(string $clientIp): array |
['recorded' => bool] |
stats(): array |
account totals |
A block is a 200 with allow => false — not an exception. Only bad input, auth,
and quota (429) throw. Point the SDK at a self-hosted instance with the second
constructor argument: new Client($key, 'https://verifence.internal').