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

ActiveLibrary

doge-dev/laravel-sms-verification
=================================

Library for sending out and verifying SMS codes using AWS SNS

0.0.2(7y ago)413.9k5[1 PRs](https://github.com/doge-dev/laravel-sms-verification/pulls)MITPHP

Since Jun 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/doge-dev/laravel-sms-verification)[ Packagist](https://packagist.org/packages/doge-dev/laravel-sms-verification)[ RSS](/packages/doge-dev-laravel-sms-verification/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

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

[](#laravel-sms-verification)

Library for sending out and verifying SMS codes using AWS SNS

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 doge-dev/laravel-sms-verification
```

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

```
DogeDev\SMSVerification\SMSVerificationServiceProvider::class,
```

Add your AWS credentials to you .env file:

```
DOGEDEV_AWS_SMS_ID=your-aws-access-key-id
DOGEDEV_AWS_SMS_SECRET=your-aws-secret-access-key

```

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

You can add SMS verification to any model by adding the VerifiesSMS trait supplied in this library, 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):

```
