{"id":19059546,"url":"https://github.com/vaibhavpandeyvpz/msg91-php","last_synced_at":"2026-04-18T10:35:26.841Z","repository":{"id":57076578,"uuid":"317295364","full_name":"vaibhavpandeyvpz/msg91-php","owner":"vaibhavpandeyvpz","description":"PHP client for sending SMS/OTP using MSG91, includes optional support for Laravel.","archived":false,"fork":false,"pushed_at":"2022-08-25T04:38:33.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T23:16:00.094Z","etag":null,"topics":["laravel","msg91","sms"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vaibhavpandeyvpz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-30T17:21:01.000Z","updated_at":"2022-08-25T04:39:23.000Z","dependencies_parsed_at":"2022-08-24T14:40:29.262Z","dependency_job_id":null,"html_url":"https://github.com/vaibhavpandeyvpz/msg91-php","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/vaibhavpandeyvpz/msg91-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaibhavpandeyvpz%2Fmsg91-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaibhavpandeyvpz%2Fmsg91-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaibhavpandeyvpz%2Fmsg91-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaibhavpandeyvpz%2Fmsg91-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaibhavpandeyvpz","download_url":"https://codeload.github.com/vaibhavpandeyvpz/msg91-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaibhavpandeyvpz%2Fmsg91-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31966098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","msg91","sms"],"created_at":"2024-11-09T00:10:30.391Z","updated_at":"2026-04-18T10:35:26.803Z","avatar_url":"https://github.com/vaibhavpandeyvpz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vaibhavpandeyvpz/msg91\nPHP client for sending SMS/OTP using MSG91, includes optional support for Laravel.\n\n### Installation\n\n```bash\ncomposer require vaibhavpandeyvpz/msg91\n```\n\n#### Laravel \u003c 5.5\nOnce the package is installed, open your `app/config/app.php` configuration file and locate the `providers` key. Add the following line to the end:\n\n```php\nMsg91\\Laravel\\ServiceProvider::class\n```\n\nNext, locate the `aliases` key and add the following line:\n\n```php\n'Msg91' =\u003e Msg91\\Laravel\\Facade::class,\n```\n\n### Configuration\nYou need to add `MSG91_KEY` in your project's `.env` file. You can also publish the default configuration file as `config/msg91.php` using below command.\n\n```bash\n$ php artisan vendor:publish\n```\n\n### Usage\n\n## Basic\n- Send an SMS to one or more numbers.\n```php\n\u003c?php\n\n// send an SMS to one number\n$result = Msg91::sms(\n    '919999999999',\n    'Hello there!',\n    'MSGIND',\n    4 /* 1 = Promotional; 4 = Transactional */,\n    [\n        'DLT_TE_ID' =\u003e '\u003cdlt-registered-template-id\u003e',\n    ]\n);\n\n// send same/different SMS to multiple numbers\n$result = Msg91::sms(\n    null,\n    [\n        ['to' =\u003e ['919999999999', '918888888888'], 'message' =\u003e 'Hello fellas!'],\n        ['to' =\u003e ['917777777777'], 'message' =\u003e 'Hello vpz!'],\n    ],\n    'MSGIND',\n    4 /* 1 = Promotional; 4 = Transactional */,\n    [\n        'DLT_TE_ID' =\u003e '\u003cdlt-registered-template-id\u003e',\n    ]\n);\n```\n\n- Send OTP to a number.\n```php\n\u003c?php\n\n$result = Msg91::otp('919999999999', 'MSGIND', [\n    'template_id' =\u003e '\u003cmsg91-approved-otp-template-id\u003e',\n]);\n```\n\n- Retry OTP (as voice) to a number.\n```php\n\u003c?php\n\n$result = Msg91::retry('919999999999', true); // returns true or false\n```\n\n- Verify OTP sent to a number.\n```php\n\u003c?php\n\n$result = Msg91::verify('919999999999', 1290); // returns true or false\n```\n\n## Notification\nInclude `msg91` in your notification's channels:\n```php\n\u003c?php\n\n/**\n * @param  mixed  $notifiable\n * @return array\n */\npublic function via($notifiable)\n{\n    return ['msg91'];\n}\n```\n\nDefine the `toMsg91` method:\n```php\n\u003c?php\n\nuse Msg91\\Laravel\\Notification\\Message as Msg91Message;\n\npublic function toMsg91()\n{\n    return (new Msg91Message)\n        -\u003emessage(__('This is just a test message.'))\n        -\u003esender('MSGIND')\n        -\u003etransactional()\n        -\u003eoptions([\n            'DLT_TE_ID' =\u003e '\u003cdlt-registered-templated-id\u003e',\n        ]);\n}\n```\n\nImplement `routeNotificationForMsg91` method in your notifiable class:\n```php\n\u003c?php\n\npublic function routeNotificationForMsg91($notification)\n{\n    return $this-\u003ephone;\n}\n```\n\nFinally send the notification:\n```php\n\u003c?php\n\n$notifiable = /* some class */\n$notifiable-\u003enotify(new App\\Notifications\\Msg91TestNotification());\n```\n\nFor sending the notification to an arbitrary number, use below syntax:\n```php\n\u003c?php\nuse Illuminate\\Support\\Facades\\Notification;\n\nNotification::route('msg91', '919999999999')\n    -\u003enotify(new App\\Notifications\\Msg91TestNotification());\n```\n\n## Validator\nYou can validate sent OTPs using provided validation rule named `msg91_otp` as shown below:\n```php\n\u003c?php\n\nuse Illuminate\\Support\\Facades\\Validator;\n\n$data = ['phone' =\u003e '919999999999', 'otp' =\u003e '1234'];\n\n$validator = Validator::make($data, [\n    'phone' =\u003e ['required', 'digits_between:10,12'],\n    'otp' =\u003e ['required', 'digits:4', 'msg91_otp'], // default key for source number is 'phone', you can customize this using 'msg91_otp:key_name'\n]);\n\nif ($validator-\u003efails()) {\n    // report errors\n}\n```\n\n### License\n\nSee [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaibhavpandeyvpz%2Fmsg91-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaibhavpandeyvpz%2Fmsg91-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaibhavpandeyvpz%2Fmsg91-php/lists"}