Download the PHP package aslnbxrz/simple-otp without Composer
On this page you can find all versions of the php package aslnbxrz/simple-otp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aslnbxrz/simple-otp
More information about aslnbxrz/simple-otp
Files in aslnbxrz/simple-otp
Package simple-otp
Short Description A simple and flexible OTP (One-Time Password) management package for Laravel with multiple storage drivers and delivery methods
License MIT
Informations about the package simple-otp
SimpleOTP Laravel Package
A simple, flexible, and production-ready OTP (One-Time Password) management package for Laravel applications. This package provides multiple storage drivers (Cache, Database, Redis) and delivery methods (SMS, Email, Log) with comprehensive configuration options.
Features
- ๐ Multiple Storage Drivers: Cache, Database, Redis
- ๐ฑ Multiple Delivery Methods: SMS (Twilio, Nexmo), Email, Log
- โก High Performance: Optimized for production use
- ๐ Security Features: Rate limiting, attempt tracking, automatic cleanup
- ๐จ Flexible Configuration: Customizable code types, lengths, TTL, and messages
- ๐งช Well Tested: Comprehensive test coverage
- ๐ฆ Laravel Integration: Service provider, facades, and artisan commands
Installation
Via Composer
Publish Configuration
Publish Migrations (for database storage)
Publish Email Views (optional)
Configuration
The package configuration file will be published to config/simple-otp.php. Here's an overview of the main configuration options:
Storage Configuration
Delivery Configuration
OTP Configuration
Environment Variables
Add these variables to your .env file:
Usage
Basic Usage with Facade
Usage in Controllers
Custom SMS/Email Messages
Storage Drivers
Cache Storage (Default)
- Uses Laravel's cache system
- Automatic expiration
- High performance
- Suitable for most applications
Database Storage
- Persistent storage
- Better for distributed applications
- Requires migration
- Automatic cleanup available
Redis Storage
- High performance
- Distributed caching
- Automatic expiration
- Best for high-traffic applications
Delivery Drivers
SMS Driver
Currently supports:
- Twilio: Popular SMS service provider
- Nexmo (Vonage): International SMS service
- Eskiz: Uzbekistan SMS service provider (using native cURL)
- Telegram: Telegram Bot API for instant messaging
Email Driver
- Uses Laravel's mail system
- Customizable templates
- HTML and text versions
Log Driver
- For development and testing
- Logs OTP codes to Laravel logs
- No external dependencies
Advanced Features
Rate Limiting
The package includes built-in rate limiting to prevent abuse:
Custom Code Types
Generate different types of OTP codes:
Automatic Cleanup
Expired OTP codes are automatically cleaned up based on configuration:
Testing
The package includes comprehensive tests. To run them:
Error Handling
The package throws specific exceptions that you can catch and handle:
Security Considerations
- Rate Limiting: Always enable rate limiting in production
- TTL: Use appropriate TTL values (5-10 minutes recommended)
- Max Attempts: Limit verification attempts (3-5 recommended)
- Storage: Use Redis or Database for production (not cache)
- HTTPS: Always use HTTPS in production
- Cleanup: Enable automatic cleanup of expired codes
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for your changes
- Run the test suite
- Submit a pull request
License
This package is open-sourced software licensed under the MIT license.
Support
For support, please open an issue on the GitHub repository.
Changelog
v1.0.0
- Initial release
- Multiple storage drivers (Cache, Database, Redis)
- Multiple delivery methods (SMS, Email, Log)
- Rate limiting and security features
- Comprehensive test coverage
- Laravel integration with facades and service providers
All versions of simple-otp with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/cache 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