PHPackages                             ronuz/laravel-sms-verification - 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. ronuz/laravel-sms-verification

ActiveLibrary

ronuz/laravel-sms-verification
==============================

Library for sending out and verifying SMS codes using AWS SNS

148↓50%1[1 PRs](https://github.com/RonaldNolascoU/laravel-sms-verification/pulls)PHP

Since Nov 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/RonaldNolascoU/laravel-sms-verification)[ Packagist](https://packagist.org/packages/ronuz/laravel-sms-verification)[ RSS](/packages/ronuz-laravel-sms-verification/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-sms-verification
========================

[](#laravel-sms-verification)

Library for sending out and verifying SMS codes using AWS SNS

This package is taken from it's original author: doge-dev. Now optimized for Laravel 6.\*

The package has a trait and a custom validation rule that you can use on any model for verifying with an SMS code.

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Example](#example)
- [Sending out the SMS code](#sending-out-the-sms-code)
- [Verifying the SMS code](#verifying-the-sms-code)
- [Setting SMS verification attempt limits](#setting-sms-verification-attempt-limits)
- [Adding custom Validation for verifying an SMS code](#adding-custom-validation-for-verifying-an-sms-code)
- [Adding custom Validation for verifying an SMS code using route model binding](#adding-custom-validation-for-verifying-an-sms-code-using-route-model-binding)
- [Changing the SMS message being sent](#changing-the-sms-message-being-sent)
- [Changing the SMS sender](#changing-the-sms-sender)

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

[](#installation)

Pull the lib with composer:

```
composer require ronuz/laravel-sms-verification
```

Add the service provider in `config/app.php`

```
Ronuz\SMSVerification\SMSVerificationServiceProvider::class,
```

Add your AWS credentials to you .env file:

```
OTP_AWS_SMS_ID=your-aws-access-key-id
OTP_AWS_SMS_SECRET=your-aws-secret-access-key,

```

NOTE: Please reffer to AWS documentation for best practices regarding AWS credentials and possibly consider creating a dedicated user with limitted privileges only for sending SMS messages

You can add SMS Verification to any model, and it will create:

- a function **setSMSVerificationNumber($mobile)** - sets the mobile number and sends out the SMS message containg the verification code
- a function **verifySMSCode($code)** -verifies the SMS code
- and a bunch of private methods that are used for verifying the SMS code. You can check them out in the Trait itself for more details.

Example
-------

[](#example)

Add the `VerifiesSMSCode` trait to your User model (or any other model on which you might want to enable 2FA):

```
