Download the PHP package litepie/otp without Composer
On this page you can find all versions of the php package litepie/otp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package otp
Short Description A comprehensive Laravel package for generating, signing and managing OTP codes with multiple channels support
License MIT
Homepage https://github.com/litepie/otp
Informations about the package otp
Laravel OTP Package
A comprehensive Laravel package for generating, signing and managing OTP (One-Time Password) codes with multiple channels support.
๐ Requirements
- PHP 8.2 or higher
- Laravel 10.0, 11.0, or 12.0
๐ Features
- โ Secure OTP Generation - Generate cryptographically secure OTP codes
- โ Digital Signing - Sign OTP codes for enhanced security and verification
- โ Multiple Delivery Channels - Email, SMS, Database, and custom channels
- โ Flexible Configuration - Customizable length, format, and expiration
- โ Rate Limiting - Built-in protection against abuse
- โ Multiple OTP Types - Login, email verification, password reset, 2FA, etc.
- โ Event System - Complete lifecycle events for monitoring and logging
- โ Queue Support - Background processing for sending OTPs
- โ Auto-cleanup - Automatic removal of expired OTPs
- โ Laravel 12 Ready - Full compatibility with the latest Laravel versions
- โ Production Ready - Thoroughly tested and optimized for production use
๐ฆ Installation
You can install the package via Composer:
Publish Configuration
Publish the configuration file:
Run Migrations
Run the migrations to create the OTPs table:
Set Up Automatic Cleanup (Optional)
Add the following to your app/Console/Kernel.php file to automatically clean up expired OTPs:
๐ง Configuration
The configuration file config/otp.php allows you to customize:
- Default OTP Settings - Length, format, expiration, channels
- OTP Types - Specific settings for different use cases
- Rate Limiting - Prevent abuse with configurable limits
- Digital Signing - Secure OTP verification
- Channel Configuration - Email, SMS, and custom channel settings
- Automatic Cleanup - Keep your database clean
Environment Variables
Add these to your .env file:
๐ Usage
Quick Start
Advanced Usage
Exception Handling
๐ฏ OTP Types
The package supports multiple OTP types with individual configurations:
Built-in Types
| Type | Use Case | Default Length | Default Expiry |
|---|---|---|---|
login |
User authentication | 6 digits | 5 minutes |
email_verification |
Email verification | 6 digits | 10 minutes |
password_reset |
Password reset | 8 characters | 15 minutes |
two_factor |
2FA authentication | 6 digits | 3 minutes |
phone_verification |
Phone verification | 6 digits | 5 minutes |
Custom Types
Define custom OTP types in your configuration:
๐ก Delivery Channels
Email Channel
Sends OTP via email using Laravel's notification system or traditional mail.
SMS Channel
Send OTPs via SMS using various providers:
Supported SMS Providers:
- Log (for testing)
- Nexmo/Vonage
- Twilio
- Custom providers (extensible)
Database Channel
Store OTP in database for manual retrieval:
Multiple Channels
Send via multiple channels simultaneously:
Custom Channels
Create custom delivery channels:
๐ Events
The package fires comprehensive events for monitoring and logging:
Available Events
OtpGenerated- When an OTP is generatedOtpSent- When an OTP is sent via a channelOtpVerified- When an OTP is successfully verifiedOtpFailed- When OTP verification fails
Event Listeners
Example Listener
๐ ๏ธ Artisan Commands
Cleanup Expired OTPs
๐ Security Features
- Digital Signing - All OTPs are digitally signed using HMAC-SHA256
- Rate Limiting - Configurable rate limiting per identifier and type
- Secure Generation - Cryptographically secure random code generation
- Attempt Tracking - Track and limit verification attempts
- Automatic Cleanup - Remove expired OTPs automatically
- Timing Attack Protection - Use
hash_equals()for secure comparisons
๐งช Testing
Running Tests
Test Example
๐ Documentation
- Examples - Comprehensive usage examples
- Contributing - How to contribute
- Security - Security policy
- Changelog - Version history
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development Setup
๐ Security
If you discover a security vulnerability, please send an email to [email protected]. All security vulnerabilities will be promptly addressed.
๐ License
The MIT License (MIT). Please see License File for more information.
๐ Support
- โญ Star this repo if you find it helpful
- ๐ Report issues on GitHub Issues
- ๐ก Request features via GitHub Discussions
- ๐ง Contact us at [email protected]
Made with โค๏ธ by Litepie
All versions of otp with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/mail Version ^10.0|^11.0|^12.0
illuminate/notifications Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0