GateWire is a decentralized mesh network that allows developers to send OTPs, notifications, and alerts to North African carriers (Mobilis, Djezzy, Ooredoo) reliably and at a fraction of the cost of international gateways.
# GateWire PHP SDK
The official PHP library for the **GateWire SMS Infrastructure**.
GateWire is a decentralized mesh network that lets developers send OTPs to North African carriers
(**Mobilis**, **Djezzy**, **Ooredoo**) reliably and at a fraction of the cost of international gateways.
---
## Requirements
- PHP **8.1** or higher
- Composer
- `guzzlehttp/guzzle` — installed automatically by Composer
---
## Installation
```bash
composer require gatewire/client
```
---
## Quick Start
The typical OTP flow uses three methods in sequence.
### 1. Initialize the client
Obtain your API token from the GateWire Dashboard.
```php
require 'vendor/autoload.php';
use GateWire\GateWire;
$gw = new GateWire('YOUR_API_TOKEN');
```
### 2. Send an OTP
```php
use GateWire\Exceptions\GateWireException;
try {
$res = $gw->dispatch('+213555123456', 'login_otp');
// $res['reference_id'] => "wg_01HX..."
// $res['status'] => "pending"
$referenceId = $res['reference_id'];
} catch (GateWireException $e) {
echo 'Error ' . $e->getCode() . ': ' . $e->getMessage();
}
```
The second argument (`template_key`) is optional. When omitted, the backend uses your account's
default OTP template. The message content is always controlled server-side — there is no message
body parameter.
### 3. Verify the OTP
Once the user submits the code they received, verify it:
```php
try {
$result = $gw->verifyOtp($referenceId, $userEnteredCode);
// $result['status'] => "verified"
// $result['message'] => "Success"
} catch (GateWireException $e) {
// code 400: invalid, expired, cancelled, or already used
echo 'Verification failed: ' . $e->getMessage();
}
```
### 4. Check OTP status
Poll or webhook-verify the delivery status at any point:
```php
$info = $gw->status($referenceId);
// $info['reference_id'] => "wg_01HX..."
// $info['status'] => "sent"
// $info['created_at'] => "2026-03-03T14:22:00Z"
```
---
## OTP Lifecycle
```
pending → dispatched → sent → verified (hap …