The official PHP library for the GateWire SMS Infrastructure.
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.
- 🚀 Decentralized Routing: Bypasses international aggregators for lower latency.
- 💰 Local Pricing: Pay in DZD (Algerian Dinar) without Forex fees.
- 🔒 Secure: All traffic is encrypted via TLS 1.3.
- ⚡ Async Support: Fire-and-forget dispatch with webhook delivery reports.
- PHP 8.1 or higher
- Composer
guzzlehttp/guzzle(Installed automatically)
Install the package via Composer:
composer require gatewire/clientQuick StartFirst, obtain your API Key from the GateWire Dashboard.
require 'vendor/autoload.php';
use GateWire\GateWire;
// Initialize with your API Key
$gatewire = new GateWire('sk_live_YOUR_API_KEY_HERE');Send a simple text message to any Algerian number (+213).
try {
$response = $gatewire->dispatch(
to: '+213555123456',
message: 'Your verification code is 849201'
);
echo "Success! Reference ID: " . $response['reference_id'];
} catch (\GateWire\Exceptions\GateWireException $e) {
echo "Error: " . $e->getMessage();
}For OTPs and 2FA, we highly recommend using Templates. This ensures your message skips the standard queue and uses the High Priority lane.
$response = $gatewire->dispatch(
to: '+213555123456',
options: [
'template_key' => 'login_otp', // Defined in your dashboard
'priority' => 'high' // Force high priority routing
]
);Retrieve your current remaining credit balance in DZD.
$balance = $gatewire->getBalance();
echo "Current Balance: " . $balance . " DZD";If you are using Laravel, you can register the client as a singleton in your AppServiceProvider.
app/Providers/AppServiceProvider.php
use GateWire\GateWire;
public function register()
{
$this->app->singleton(GateWire::class, function ($app) {
return new GateWire(config('services.gatewire.key'));
});
}
config/services.php'gatewire' => [
'key' => env('GATEWIRE_API_KEY'),
],use GateWire\GateWire;
public function sendOtp(Request $request, GateWire $gatewire)
{
$gatewire->dispatch($request->phone, 'Your code is 123456');
return response()->json(['status' => 'sent']);
}The SDK throws GateWire\Exceptions\GateWireException for any API error (4xx or 5xx). You should always wrap your calls in a try-catch block.
use GateWire\Exceptions\GateWireException;
try {
$gatewire->dispatch('+213000000000', 'Hello');
} catch (GateWireException $e) {
// Handle specific errors
if ($e->getCode() === 402) {
// "Insufficient Balance"
}
if ($e->getCode() === 503) {
// "No active devices available in the network"
}
}Email: dev@raystate.com
The GateWire PHP SDK is open-sourced software licensed under the MIT license.