PHPackages                             craftsys/msg91-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. craftsys/msg91-laravel

ActiveLibrary

craftsys/msg91-laravel
======================

Laravel service provider for Msg91 apis to Send OTPs, Verify OTPs, Resend OTPs, Send SMS (Short Message) etc

v0.15.1(1y ago)1295.8k↓12.4%8[1 issues](https://github.com/craftsys/msg91-laravel/issues)[1 PRs](https://github.com/craftsys/msg91-laravel/pulls)1MITPHPPHP ^7.1.3|^8.0|^8.1|^8.2CI failing

Since Oct 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/craftsys/msg91-laravel)[ Packagist](https://packagist.org/packages/craftsys/msg91-laravel)[ Docs](https://github.com/craftsys/msg91-laravel)[ RSS](/packages/craftsys-msg91-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (33)Used By (1)

Laravel service provider for Msg91
==================================

[](#laravel-service-provider-for-msg91)

[![Total Downloads](https://camo.githubusercontent.com/0a1bf316c46c82619fbc9f5166404dde5d3e176807183228aa87fa0e65d84182/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63726166747379732f6d736739312d6c61726176656c)](https://packagist.org/packages/craftsys/msg91-laravel)[![Latest Stable Version](https://camo.githubusercontent.com/5a94acc2c5dcfd364cf63cb36d6df295c1c2c8f9a162c7398e5b1541860c5486/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63726166747379732f6d736739312d6c61726176656c3f6c6162656c3d76657273696f6e)](https://packagist.org/packages/craftsys/msg91-laravel)[![License](https://camo.githubusercontent.com/28fba06e2879f7b5254da4bdf276bba2b7ee1929b8e22ceb25db9ea3b2bcffce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63726166747379732f6d736739312d6c61726176656c)](https://packagist.org/packages/craftsys/msg91-laravel)[![Status](https://github.com/craftsys/msg91-laravel/actions/workflows/test.yml/badge.svg)](https://github.com/craftsys/msg91-laravel/actions/workflows/test.yml)

This is a **[laravel](https://laravel.com) service provider** for [Msg91 APIs](https://docs.msg91.com/collection/msg91-api-integration/5/pages/139). It wraps the [msg91-php](https://github.com/craftsys/msg91-php) client and provides the same functionality for Laravel applications by exposing a Service Provider and Facade.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Examples](#examples)
    - [Managing OTPs](#managing-otps)
        - [Send OTP](#send-otp)
        - [Verify OTP](#verify-otp)
        - [Resend OTP](#resend-otp)
    - [Sending SMS](#sending-sms)
        - [Bulk SMS](#bulk-sms)
        - [Message Variables](#message-variables)
    - [Handling Responses](#handling-responses)
- [Related](#related)
- [Acknowledgements](#acknowledgements)

Installation
------------

[](#installation)

The packages is available on [Packagist](https://packagist.org/packages/craftsys/msg91-laravel) and can be installed via [Composer](https://getcomposer.org/) by executing following command in shell.

```
composer require craftsys/msg91-laravel
```

**prerequisite**

- php^7.1
- laravel^5|^6|^7|^8|^9|^10

The package is tested for 5.8+,^6.0,^7.0,^8.0,^9.0,^10.0 only. If you find any bugs for laravel (5.0&lt; &gt;5.8), please file an issue.

### Laravel 5.5+

[](#laravel-55)

If you're using Laravel 5.5 or above, the package will automatically register the `Craftsys\Msg91\Msg91LaravelServiceProvider` provider and aliases `Craftsys\Msg91\Facade\Msg91` facade to `Msg91`.

### Laravel 5.4 and below

[](#laravel-54-and-below)

Add `Craftsys\Msg91\Msg91LaravelServiceProvider` to the `providers` array in your `config/app.php`:

```
'providers' => [
     // Other service providers...
     Craftsys\Msg91\Msg91LaravelServiceProvider::class,
],
```

If you want to use the facade interface, you can `use` the facade class when needed:

```
use Craftsys\Msg91\Facade\Msg91;
```

Or add an alias in your `config/app.php`

```
'aliases' => [
    // other aliases here
    'Msg91' => Craftsys\Msg91\Facade\Msg91::class,
],
```

To verify that everything is working as expected, excecute the following php code somewhere in your application, either in an example route or in `php artisan tinker` if you are in Laravel.

```
// this should print the `\Craftsys\Msg91\OTP\OTPService` of some default configuration values
echo Msg91::otp()::class
```

If there is an issue, please check the steps again or open an issue for support.

Configuration
-------------

[](#configuration)

As the [msg91-php](https://github.com/craftsys/msg91-php) offers configuration that are similar to Laravel's configuration, this package simply ports the Laravel's configuration to the msg91-php client.

The package can be configured by providing a `msg91` key inside your `config/services.php` configuration file.

```
