Download the PHP package ars/laravel-otp-code without Composer
On this page you can find all versions of the php package ars/laravel-otp-code. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ars/laravel-otp-code
More information about ars/laravel-otp-code
Files in ars/laravel-otp-code
Package laravel-otp-code
Short Description A Laravel package for generating, validating, and managing One-Time Passwords (OTPs) to enhance security in authentication workflows.
License MIT
Homepage https://github.com/alireza2000sajedi/otp-code-laravel
Informations about the package laravel-otp-code
OTP Code Laravel - One-Time Password In Laravel
Introduction
This Laravel package offers a comprehensive solution for generating, storing, and verifying One-Time Passwords (OTPs). It supports customizable OTP configurations, including type, length, expiration, encryption, and validation rules, ensuring secure and flexible OTP management in your Laravel applications.
Features
- Generate secure OTP codes with customizable types and lengths.
- Store and manage OTP codes with configurable expiration times.
- Optional OTP encryption for enhanced security.
- Validation rules to ensure OTP integrity.
- Seamless integration with Laravel applications.
Requirements:
- Laravel Version: 10 or higher
- PHP Version: 8.0 or higher
Installation
To install the package, follow these steps:
-
Require the package via Composer:
-
Publish the configuration file and migration:
- Run the migration:
Configuration
The configuration file otp-code.php
includes the following options:
table_name
: The name of the database table to store OTP codes.code_type
: The data type of the OTP code (int
for integers orstring
for alphanumeric).code_length
: The length of the OTP code.max_attempts
: The maximum number of attempts allowed to validate the OTP (set0
to disable attempts).expiry_time
: The time (in minutes) before the OTP expires.encrypt_code
: Whether to encrypt the OTP code before storing it.default_salt
: The default salt value to be used if none is provided.
Usage
Repository
Creating an OTP
To create an OTP, use the create
method:
Verifying an OTP
To verify an OTP, use the verify
method:
Checking OTP Existence
To check if a valid OTP exists, use the has
method:
Facade
The package provides a facade for easy access to the OTP repository:
Custom Validation Rule
The package includes a validation rule to validate OTP codes:
Example
Customization
Error Messages
You can customize the error messages by modifying the language files. Publish the language files using:
Commands
The package includes an Artisan command to purge expired OTP codes:
Conclusion
This package provides a robust solution for managing OTP codes in a Laravel application. By leveraging the repository, facade, and validation rules, you can easily integrate OTP functionality into your project.
Contributing
Contributions are welcome! Please adhere to the following guidelines:
- Fork the repository.
- Create a feature branch (git checkout -b feature/my-new-feature).
- Commit your changes (git commit -am 'Add new feature').
- Push to the branch (git push origin feature/my-new-feature).
- Open a Pull Request.
License
This library is licensed under the MIT License.
Contact
For support or questions, please open an issue on GitHub.