PHPackages                             eagleeye/otp - 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. eagleeye/otp

ActiveLibrary

eagleeye/otp
============

Laravel OTP Generator

v2.0.0(1y ago)0193↓100%MITPHP

Since Apr 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/shuvodewan/laravel-otp-generator)[ Packagist](https://packagist.org/packages/eagleeye/otp)[ RSS](/packages/eagleeye-otp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

LARAVEL OTP GENERATOR
=====================

[](#laravel-otp-generator)

A laravel package to generate OTP.

- [Installation](#installation)
- [Vendor Publication](#vendorpublish)
    - [Config](#vendor_config)
    - [Migrations](#vendor_database)
- [Configuration](#config)
    - [Prefix](#config_prefix)
    - [Type](#config_type)
    - [Length](#config_length)
    - [Storage](#config_storage)
    - [Expire](#config_expire)
    - [Case](#config_case)
    - [Table Name](#config_table)
- [Usage](#usage)
    - [Get Method](#uses_get)
    - [Interval Method](#uses_interval)
    - [Action Method](#uses_action)
    - [Interval Action Method](#uses_intervalaction)
    - [Verify](#verify)

🚀 Installation
---------------

[](#-installation-)

`Composer` will allows you to quickly install via the command line.

```
  composer require eagleeye/otp
```

🚀Vendor Publishing
------------------

[](#vendor-publishing)

---

> **NOTE**
> Publishing vendors are optional only required if you are willing to change configuration and use database as ***OTP*** storage.

Publish config file

```
php artisan vendor:publish --provider="Eagleeye\Otp\OtpServiceProvider" --tag=config
```

 Publish database migration file

```
php artisan vendor:publish --provider="Eagleeye\Otp\OtpServiceProvider" --tag=migrations
```

✨ Configuration File
---------------------

[](#-configuration-file-)

> **NOTE**
> You will find the ***OTP*** configuration file in `config` folder name as `otp.php` .

otp.php

```
null,

    /**
     * [Description for boot]
     *
     * Example: numeric         | Output  12345678
     * Example: alphabetic      | Output  ktylnfdgf
     * Example: alphanumeric    | Output  kt7l7fdg9
     * Example: mixnumeric      | Output  !45'numeric',

    /**
     * [Description for length]
     *
     * Example: 6    | Output 123456
     * Example: 8    | Output 12345678
     *
     */
    'length'=>'6',

    /**
     * [Description for Mood]
     *
     * @return [type]
     *
     */
    'mood'=>env('APP_ENV'),

    /**
     * [Description for storage]
     *
     * Example: databse     | OTP will store in databse
     * Example: cache       | OTP will store in cache
     * Example: session     | OTP will store in session
     */
    'storage'=>'database',

    /**
     * [Description for expire]
     *
     * OTP expire time
     * In seconds
     *
     */
    'expire'=>"60",

    /**
     * [Description for history]
     *
     * If true previous expired or validated otp wont delete
     * In boolean
     *
     */
    'history'=>false,

    /**
     * [Description for resend_in]
     *
     * Resend remaining time for interval mode
     * Should be smaller then expire time
     * In seconds
     *
     */
    'resend_in'=>"60",

    /**
     * [Description for duplicate]
     *
     * Send previously generated for resend till expire or validate
     * In boolean
     * Duplicate till expired
     *
     */
    'duplicate'=>false,

    /**
     * [Description for case]
     *
     * Example: lower    | Output werfghyt
     * Example: upper    | Output AFKUTDFG
     */
    'case'=>'lower',

    /**
     * [Description for table_name]
     *
     * Table name to create table in databse
     *
     */
    'table_name'=>'otp_table'
];

```

- ### Prefix

    [](#prefix)

    - The `prefix` default value is `null`. If you would like to add a text or trademark or a single character like `google` registration `OTP` in every generated otp, Just add the prefix value.&lt;br&gt; `Prefix` and Actual `OTP` will be seperated by a ( `-` )

        PrefixWithout PrefixWith PrefixP12345678P-12345678
- ### type

    [](#type)

    - The `type` represent `OTP` string type .default value is `numeric`.&lt;br&gt; `Prefix` and Actual `OTP` will be seperated by a `-`

        TypeOutputCharacter Typesnumeric12345678NumberalphabeticktylnfdgfAlphabetalphanumerickt7l7fdg9Number,Alphabetmixnumeric!45&lt;45!Number,Special Charactermixalphabetic!tad%hgrAlphabet,Special Charactermixalphanumeric!t4&lt;7g!Number,Alphabet,Special Character
- ### Length

    [](#length)

    - The `length` represent total number of character's in generated `OTP` .Default length is ***6***.

        LengthOTP6123456812345678
- ### Storage

    [](#storage-)

    - `Cache Storage` used as default storage to store ***OTP*** .Dont forget to publish ***Otp migration*** file before using `database` as OTP storage. #### storage Options:

        [](#storage-options)

        - `cache`
        - `session`
        - `database`
- ### Expire

    [](#expire)

    - `expire` - The validity period of the OTP in seconds
- ### Case

    [](#case-)

    - The `case` - differentiating between capital and lower-case letters.

        CaseOTPlowergeneratorupperGENERATOR
- ### Table Name

    [](#table-name-)

    - `table_name` - With the name OTP databse migration table will be created .`otp_table` is default table name.

🚀Usage
-------

[](#usage-)

Import OTP facade

```
  use Eagleeye\Otp\Facades\OTP;
```

### Static Function : get

[](#static-function--get)

```
//Facade accessor public function
public function get(String $key)
{
         //processing...
}
```

This will generate a OTP that valid till expire time(`configured in config file`),For every otp request the method response new otp string with new expire time:

- `$key`: The key that will be tied to the OTP.

#### Example

[](#example)

```
