PHPackages                             simpleverify/simpleverify-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. simpleverify/simpleverify-php

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

simpleverify/simpleverify-php
=============================

PHP client library for the SimpleVerify API - developer-first verification alerts (SMS, email, magic link)

v1.0.1(3mo ago)00MITPHPPHP ^8.1CI passing

Since Apr 8Pushed 3mo agoCompare

[ Source](https://github.com/SimpleVerify/simpleverify-php)[ Packagist](https://packagist.org/packages/simpleverify/simpleverify-php)[ Docs](https://simpleverify.com)[ RSS](/packages/simpleverify-simpleverify-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

SimpleVerify PHP SDK
====================

[](#simpleverify-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/7495cad4129bc2ec0066a948dff45c01d4b8250954d106512915a79e4c4ebc7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696d706c657665726966792f73696d706c657665726966792d7068702e737667)](https://packagist.org/packages/simpleverify/simpleverify-php)[![Total Downloads](https://camo.githubusercontent.com/ba6ba97c672a442e3f621e3bd963077b9461ba20ce4dcb7b653b9fdfc1a73c83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696d706c657665726966792f73696d706c657665726966792d7068702e737667)](https://packagist.org/packages/simpleverify/simpleverify-php)[![PHP Version Require](https://camo.githubusercontent.com/ab6d1488c68107fcda542703f05db79122f164293418989833942151704a4726/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73696d706c657665726966792f73696d706c657665726966792d7068702e737667)](https://packagist.org/packages/simpleverify/simpleverify-php)[![License](https://camo.githubusercontent.com/57e012dbcc459eb55ea805b99b449709916c4b0f84f3824a0655e520f5979e77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73696d706c657665726966792f73696d706c657665726966792d7068702e737667)](https://packagist.org/packages/simpleverify/simpleverify-php)[![Tests](https://github.com/SimpleVerify/simpleverify-php/actions/workflows/tests.yml/badge.svg)](https://github.com/SimpleVerify/simpleverify-php/actions/workflows/tests.yml)

Official PHP client library for the [SimpleVerify](https://simpleverify.io) API. Send and verify SMS codes, email codes, and magic links with a few lines of code.

Requirements
------------

[](#requirements)

- PHP 8.1+
- cURL extension
- JSON extension

Installation
------------

[](#installation)

```
composer require simpleverify/simpleverify-php
```

Quick Start
-----------

[](#quick-start)

```
use SimpleVerify\Client;

$client = new Client('vk_test_your_api_key_here');

// Send an SMS verification
$verification = $client->verifications->send([
    'type' => 'sms',
    'destination' => '+15551234567',
]);

echo $verification->verificationId; // "a1b2c3d4-..."
echo $verification->status;          // "pending"

// Check the code the user entered
$result = $client->verifications->check($verification->verificationId, '482913');

if ($result->valid) {
    echo 'Verified!';
}
```

Usage
-----

[](#usage)

### Initialize the Client

[](#initialize-the-client)

```
// With just an API key
$client = new Client('vk_test_...');

// With options
$client = new Client([
    'api_key'  => 'vk_test_...',
    'base_url' => 'https://api.simpleverify.io', // default
    'timeout'  => 30,                              // default, in seconds
]);

// Static factory
$client = \SimpleVerify\SimpleVerify::make('vk_test_...');
```

### Send a Verification

[](#send-a-verification)

```
// SMS
$verification = $client->verifications->send([
    'type' => 'sms',
    'destination' => '+15551234567',
]);

// Email
$verification = $client->verifications->send([
    'type' => 'email',
    'destination' => 'user@example.com',
]);

// Magic link
$verification = $client->verifications->send([
    'type' => 'magic_link',
    'destination' => 'user@example.com',
    'redirect_url' => 'https://yourapp.com/dashboard',
    'failure_redirect_url' => 'https://yourapp.com/auth/magic-link-result',
]);

// With metadata
$verification = $client->verifications->send([
    'type' => 'sms',
    'destination' => '+15551234567',
    'metadata' => ['user_id' => 42],
]);
```

The response is a `Verification` object:

```
$verification->verificationId; // UUID
$verification->type;           // "sms", "email", or "magic_link"
$verification->destination;    // masked: "*******4567" or "u***@example.com"
$verification->status;         // "pending"
$verification->expiresAt;      // ISO 8601 datetime
$verification->environment;    // "test" or "live"
```

### Test Mode

[](#test-mode)

When using a `vk_test_` API key, the response includes the code or token so you can complete the flow without real SMS/email delivery:

```
$verification->test->code;  // "482913" (SMS/email)
$verification->test->token; // 64-char string (magic link)
```

In live mode (`vk_live_` key), `$verification->test` is `null`.

If you set `failure_redirect_url` on a magic link, failed clicks redirect there with `status` (`invalid`, `expired`, or `already_used`) and `verification_id` query parameters.

Successful magic link clicks redirect with `status=verified`, `verification_id`, and a one-time `exchange_code`. Redeem that code from your backend:

```
$exchange = $client->verifications->exchange($verificationId, $exchangeCode);

$exchange->destination; // verified email address
$exchange->metadata;    // original metadata array
```

### Check a Code

[](#check-a-code)

```
$result = $client->verifications->check($verification->verificationId, '482913');

$result->valid;          // true or false
$result->verificationId; // UUID
$result->type;           // present when valid
$result->destination;    // present when valid (masked)
```

An invalid code returns `valid: false` (not an exception). Only check the `valid` field.

### Get Verification Status

[](#get-verification-status)

```
$status = $client->verifications->get($verification->verificationId);

$status->status;    // "pending", "verified", or "expired"
$status->createdAt; // ISO 8601 datetime
```

Error Handling
--------------

[](#error-handling)

All API errors throw specific exceptions extending `SimpleVerifyException`:

```
use SimpleVerify\Exceptions\AuthenticationException;
use SimpleVerify\Exceptions\ValidationException;
use SimpleVerify\Exceptions\RateLimitException;
use SimpleVerify\Exceptions\NotFoundException;
use SimpleVerify\Exceptions\SimpleVerifyException;

try {
    $client->verifications->send([...]);
} catch (RateLimitException $e) {
    $seconds = $e->getRetryAfter();
    echo "Rate limited. Retry in {$seconds} seconds.";
} catch (ValidationException $e) {
    $errors = $e->getDetails();
    // ["destination" => ["Invalid phone number format."]]
} catch (AuthenticationException $e) {
    echo "Bad API key: " . $e->getErrorCode();
} catch (NotFoundException $e) {
    echo "Verification not found.";
} catch (SimpleVerifyException $e) {
    // Catch-all for any API error
    $e->getHttpStatus();  // HTTP status code
    $e->getErrorCode();   // API error code string
    $e->getMessage();     // Human-readable message
    $e->getDetails();     // Additional context array
}
```

HTTP StatusException401`AuthenticationException`404`NotFoundException`422`ValidationException`429`RateLimitException`Other`ApiException`Network failure`ConnectionException`Testing
-------

[](#testing)

The client accepts a custom HTTP client for testing. See the `tests/` directory for examples using `MockHttpClient`.

```
composer install
./vendor/bin/phpunit
```

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance82

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

2

Last Release

93d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57faf02cb728789f5bb1242a73090ac1e9040ca9c10baf655e3a7e72d555d9ad?d=identicon)[SimpleVerify](/maintainers/SimpleVerify)

---

Top Contributors

[![danrovito](https://avatars.githubusercontent.com/u/8322674?v=4)](https://github.com/danrovito "danrovito (10 commits)")

---

Tags

otpemail2fasmsverificationmagic-linksimpleverify

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/simpleverify-simpleverify-php/health.svg)

```
[![Health](https://phpackages.com/badges/simpleverify-simpleverify-php/health.svg)](https://phpackages.com/packages/simpleverify-simpleverify-php)
```

###  Alternatives

[ferdous/laravel-otp-validate

Laravel package for OTP validation with built-in features like retry and resend mechanism. Built in max retry and max resend blocking. OTP/Security Code can be send over SMS or Email of your choice with user-defined template.

7124.6k](/packages/ferdous-laravel-otp-validate)[alexgeno/phone-verification-laravel

A library for phone verification via Laravel notification channels. Any notification channel can be used as a sender, and Redis or MongoDB can be used as a storage.

112.6k](/packages/alexgeno-phone-verification-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
