1. Go to this page and download the library: Download ghanem/laravel-smsmisr library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ghanem / laravel-smsmisr example snippets
use Ghanem\LaravelSmsmisr\Facades\Smsmisr;
$response = Smsmisr::send('Hello world', '01012345678');
if ($response->isSuccessful()) {
echo $response->message;
}
$response = Smsmisr::send(
message: 'Happy Birthday!',
to: '01012345678',
scheduledAt: new DateTime('2026-04-01 09:00:00'),
);
// Also works with bulk
$response = Smsmisr::sendBulk(
message: 'Sale starts now!',
recipients: ['01012345678', '01112345678'],
scheduledAt: new DateTime('2026-04-01 09:00:00'),
);
use Ghanem\LaravelSmsmisr\Facades\Smsmisr;
// Queue a single SMS
Smsmisr::queue('Hello', '01012345678');
// Queue bulk SMS
Smsmisr::queueBulk('Hello everyone', ['01012345678', '01112345678']);
// Queue verification SMS
Smsmisr::queueVerify('1234', '01012345678', null, 'your-template');
use Ghanem\LaravelSmsmisr\Jobs\SendSmsJob;
use Ghanem\LaravelSmsmisr\Jobs\SendBulkSmsJob;
use Ghanem\LaravelSmsmisr\Jobs\SendVerifySmsJob;
SendSmsJob::dispatch('Hello', '01012345678');
SendBulkSmsJob::dispatch('Hello', ['01012345678', '01112345678']);
SendVerifySmsJob::dispatch('1234', '01012345678', null, 'template');
use Ghanem\LaravelSmsmisr\Exceptions\SmsmisrApiException;
use Ghanem\LaravelSmsmisr\Exceptions\SmsmisrAuthenticationException;
use Ghanem\LaravelSmsmisr\Exceptions\SmsmisrInsufficientBalanceException;
use Ghanem\LaravelSmsmisr\Exceptions\SmsmisrRateLimitException;
try {
$response = Smsmisr::send('Hello', '01012345678');
} catch (SmsmisrAuthenticationException $e) {
// Invalid credentials
} catch (SmsmisrInsufficientBalanceException $e) {
// Not enough SMS credits
} catch (SmsmisrRateLimitException $e) {
// Rate limit exceeded
} catch (SmsmisrApiException $e) {
$e->getCode(); // Error code
$e->getMessage(); // Error message
$e->getResponse(); // Full response array
}
use Ghanem\LaravelSmsmisr\Rules\EgyptianPhoneNumber;
$request->validate([
'phone' => ['
use Ghanem\LaravelSmsmisr\Events\SmsSent;
use Ghanem\LaravelSmsmisr\Events\LowBalance;
Event::listen(SmsSent::class, function (SmsSent $event) {
logger("SMS sent to {$event->to}");
});
Event::listen(LowBalance::class, function (LowBalance $event) {
// Send alert to admin
});
namespace App\Notifications;
use Ghanem\LaravelSmsmisr\SmsmisrChannel;
use Ghanem\LaravelSmsmisr\SmsmisrMessage;
use Illuminate\Notifications\Notification;
class OrderShipped extends Notification
{
public function via($notifiable): array
{
return [SmsmisrChannel::class];
}
public function toSmsmisr($notifiable): SmsmisrMessage
{
return (new SmsmisrMessage('Your order has been shipped!', $notifiable->phone))
->sender('MyApp');
}
}
public function toSmsmisr($notifiable): SmsmisrMessage
{
return (new SmsmisrMessage())
->to($notifiable->phone)
->asVerification('1234', 'your-template-id');
}
public function toSmsmisr($notifiable): SmsmisrMessage
{
return (new SmsmisrMessage('Reminder: appointment tomorrow', $notifiable->phone))
->scheduledAt(new DateTime('2026-04-01 09:00:00'));
}
use Ghanem\LaravelSmsmisr\Facades\Smsmisr;
public function test_order_sends_sms(): void
{
Smsmisr::fake();
// ... trigger SMS ...
Smsmisr::assertSent('01012345678', 'Your order has been shipped!');
Smsmisr::assertSentCount(1);
}