kaydee123/msg91-php
PHP 8.0–8.5 client for MSG91 SMS & OTP: send single/bulk and template-based SMS, DLT-compliant messaging for India, send/verify/resend OTP (text/voice), fluent chainable API, strong error handling, framework-agnostic.
sending:otp, sms:delivered) via custom event listeners or observers.sendSmsLater()) for async processing, reducing latency in user flows.ServiceProvider (e.g., Msg91ServiceProvider) to bind the client as a singleton.Msg91::sms()->send()) for cleaner syntax in Blade/non-dependency-injected contexts.msg91.php) for auth_key, base_url, and default routes (promotional/transactional)..env conventions (e.g., MSG91_AUTH_KEY).otp_attempts table) for verification and retry logic.sms_logs table for auditing (via Laravel’s query builder or Eloquent).Mockery or createMock() for unit/feature tests.Msg91Client in Laravel’s testing setup.boot() to validate DLT templates for Indian routes.ApiException and Msg91Exception can be extended to integrate with Laravel’s exception handler (e.g., logging to Sentry or custom error pages).package:discover to auto-load the package and version-lock dependencies.Msg91Client as a singleton in AppServiceProvider with config-based auth key.Msg91 facade for Blade templates or non-injected contexts.config/msg91.php for auth_key, base_url, default_route, and timeout.send() calls in dispatch() for async processing (e.g., SendSmsJob).delay() for time-sensitive OTPs (e.g., 5-minute delay for verification).SmsSent, OtpVerified) to trigger side effects (e.g., user notifications).FormRequest or Validator.MSG91_AUTH_KEY in .env.AppServiceProvider:
public function boot()
{
$this->app->singleton(Msg91Client::class, function ($app) {
return new Msg91Client(config('msg91.auth_key'));
});
}
SendSmsJob and update Msg91Client to dispatch jobs instead of sending directly.$client->sms()->template('TEMPLATE_ID')->numbers('919876543210')->dispatch();
public function handle($request, Closure $next)
{
if ($request->routeIs('send.sms') && str_starts_with($request->mobile, '91')) {
$this->validateDltTemplate($request->template_id);
}
return $next($request);
}
sms_logs table using Laravel’s query builder.DB::table('sms_logs')->insert([
'mobile' => $mobile,
'status' => $response->status,
'message_id' => $response->message_id,
'created_at' => now(),
]);
Notification class to use Msg91Client for SMS channels.auth_key.Msg91Client in unit tests.kaydee123/msg91-php for updates and test compatibility with MSG91’s API changes.composer.json conflict rules to prevent breaking changes..env or a secrets manager (e.g., AWS Secrets Manager).config:cache to avoid runtime config reloads.deprecated tag in Laravel’s IDE helper to flag outdated Msg91Client usage.ApiException to include Laravel-specific context (e.g., user ID, request ID) for debugging.catch (ApiException $e) {
return back()->withError("OTP Error: {$e->getResponse()['message']}");
}
How can I help you explore Laravel packages today?