vantomdev/smsmisr
Composer 安装命令:
composer require vantomdev/smsmisr
包简介
OTP and SMS API integration for SmsMisr
README 文档
README
A powerful Laravel package for integrating SmsMisr OTP and SMS APIs. This package supports multiple Laravel versions up to 12.x, allowing easy and efficient management of SMS and OTP functionalities.
🌟 Features
- 🔑 Send OTPs to single mobile numbers using predefined templates.
- 📲 Send SMS to single or multiple mobile numbers.
- 🌐 Multiple languages support (English, Arabic, Unicode).
- 🔒 Rate Limiting to prevent abuse and reduce costs (Max 3 messages per minute, block for 5 minutes).
- 📘 Detailed Localization Support for multilingual websites.
- 🔄 Flexible configuration for Live and Testing environments.
- 🔧 Customizable API URLs for OTP and SMS requests.
- 💎 Seamless integration with Laravel 8.x to 12.x.
⚙️ Requirements
- PHP >= 8.1
- Laravel >= 8.x
- GuzzleHttp >= 7.5
🚀 Installation
Step 1: Install via Composer
composer require vantomdev/smsmisr
Step 2: Publish the Configuration
php artisan vendor:publish --tag=config --provider="VantomDev\SmsMisr\SmsMisrServiceProvider"
Step 3: Publish Language Files
php artisan vendor:publish --tag=lang --provider="VantomDev\SmsMisr\SmsMisrServiceProvider"
Step 4: Add Environment Variables
Add the following variables to your .env file:
SMSMISR_USERNAME=your_username SMSMISR_PASSWORD=your_password SMSMISR_SENDER=your_sender SMSMISR_ENV=2 # 1 for Live, 2 for Test # API Base URLs SMSMISR_BASE_URL_OTP=https://smsmisr.com/api/OTP/ SMSMISR_BASE_URL_SMS=https://smsmisr.com/api/SMS/ # Default Template Token SMSMISR_TEMPLATE_TOKEN=your_default_template_token # Rate Limiting (Optional) SMSMISR_RATE_LIMIT=true SMSMISR_MAX_REQUESTS=3 SMSMISR_BLOCK_DURATION=5
⏰ Rate Limiting
To prevent abuse and excessive costs, this package has built-in rate limiting.
- Maximum of 3 messages per minute per mobile number.
- If exceeded, the user is blocked for 5 minutes.
- Error message displayed using localization:
'Too many requests. Please try again after 5 minutes.'
You can customize this message in your language files or disable rate limiting by setting:
'enable_rate_limit' => false,
in config/smsmisr.php.
🌐 Localization Support
This package supports multiple languages for error messages and notifications. Default languages included:
- English (
resources/lang/vendor/smsmisr/en/messages.php) - Arabic (
resources/lang/vendor/smsmisr/ar/messages.php)
You can add more languages by creating new files under resources/lang/vendor/smsmisr/{lang_code}/messages.php.
Example:
return [ 'rate_limited' => 'Too many requests. Please try again after 5 minutes.', 'success' => 'OTP sent successfully!', ];
🔥 Usage Examples
1. Send OTP
use VantomDev\SmsMisr\Facades\SmsMisr; use VantomDev\SmsMisr\Exceptions\SmsMisrException; try { $response = SmsMisr::sendOtp('2011XXXXXXX', '123456'); return back()->with('success', __('smsmisr::messages.success')); } catch (SmsMisrException $e) { return back()->with('error', $e->getMessage()); }
2. Send SMS
use VantomDev\SmsMisr\Facades\SmsMisr; use VantomDev\SmsMisr\Exceptions\SmsMisrException; try { $response = SmsMisr::sendSms('2011XXXXXXX', 'This is a test message.', 1); # 1 For English , 2 For Arabic , 3 For Unicode return back()->with('success', __('smsmisr::messages.success')); } catch (SmsMisrException $e) { return back()->with('error', $e->getMessage()); }
🎨 Changelog
v1.2.0
- Added Configurable API URLs:
base_url_otpandbase_url_smsare now customizable. - Refactored ServiceProvider: Improved Dependency Injection for better testability.
- Improved Rate Limiting: Now configurable from
config/smsmisr.phpor.env.
v1.1.0
- Added Rate Limiting: Max 3 messages per minute, block for 5 minutes.
- Enhanced Localization Support: Multi-language support for error messages.
- Refactored ServiceProvider: Improved Dependency Injection and Interface Binding.
- Custom Exceptions and Logging: Enhanced error handling and logging mechanism.
v1.0.0
- Initial release with OTP and SMS support.
🧑💻 Contributing
- Fork the repository.
- Create a new branch (
feature/your-feature-name). - Make your changes and commit them (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a pull request.
📧 Support
For any issues, please create an issue on the GitHub Repository.
❤️ Contributors
Thanks to all contributors for helping make this package better!
⚖️ License
This project is licensed under the MIT License - see the LICENSE file for details.
🚀 Happy Coding!
vantomdev/smsmisr 适用场景与选型建议
vantomdev/smsmisr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.15k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vantomdev/smsmisr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vantomdev/smsmisr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-25