tookantech/chapaar
Composer 安装命令:
composer require tookantech/chapaar
包简介
This package provides a flexible way to send and verify messages through various SMS providers. It offers integration with multiple drivers, making it easy to use different SMS service providers without getting locked into a specific one.
关键字:
README 文档
README
Chapaar offers flexible message sending and verification through multiple SMS providers, with easy integration and no lock-in to any specific provider.
Available Drivers
- kavenegar.com (tested)
- sms.ir (tested)
- ghasedak.me (tested)
- Farapayamk (not tested)
- Twillo (coming soon)
Installation
You can install the package via Composer:
composer require tookantech/chapaar
Configuration
You can publish the config file with:
php artisan vendor:publish --tag="chapaar-config"
This will create a chapaar.php configuration file in your config directory, where you can set the default driver and configure driver-specific settings.
This is the contents of the published config file:
return [ 'default' => env('CHAPAAR_DRIVER', 'kavenegar'), 'drivers' => [ 'kavenegar' => [ 'url' => 'https://api.kavenegar.com/v1/', 'api_key' => '', 'line_number' => '' ], 'smsir' => [ 'url' => 'https://api.sms.ir/v1/', 'api_key' => '', 'line_number' => '', ], 'ghasedak' => [ 'url' => 'https://api.ghasedak.me/v2/', 'api_key' => '', 'line_number' => '', ], ], ];
Usage
Using the Chapaar Facade
If you want to use the Chapaar package without Laravel's built-in notification system, you can utilize the Chapaar facade directly. This allows you to send and verify messages using different SMS providers.
Sending a Simple Message
use TookanTech\Chapaar\Facades\Chapaar; use TookanTech\Chapaar\SmsMessage; $message = (new SmsMessage())->driver() ->setFrom('12345678') ->setTo('0912111111') ->setContent('Hello, this is a test message.'); $response = Chapaar::send($message);
Sending With Template Message
use TookanTech\Chapaar\Facades\Chapaar; use TookanTech\Chapaar\SmsMessage; #Kavenegar $message =(new SmsMessage()) ->driver() ->setTemplate("invoice-paid") ->setTo('09121111111') ->setTokens([ '123', // token '456', // token2 '789', // token3 '111', // token10, with 4 space '222', // token20, with 8 space ]); # SmsIr $message =(new SmsMessage()) ->driver() ->setTemplate('invoice-paid') ->setTo('09121111111') ->setTokens([ 'code' => '123' // 'variable_name' => 'value' ]); # Ghasedak $message =(new SmsMessage()) ->driver() ->setTemplate("invoice-paid") ->setTo('09121111111') ->setTokens([ 'test1', // param1 'test2' // param2 ]); $response = Chapaar::verify($message);
Sending Without using default driver
use TookanTech\Chapaar\Facades\Chapaar; use TookanTech\Chapaar\SmsMessage; use TookanTech\Chapaar\Enums\Drivers; $message = (new SmsMessage()) ->driver(Drivers::SMSIR) ->setFrom('12345678') ->setTo('0912111111') ->setContent('Hello, this is a test message.'); $response = Chapaar::send($message);
Get Latest Outbox messages it automatically get the latest sent messages for default driver
$response = Chapaar::outbox(100);
Using In Notifications
Please review laravel notifications on how use notifications in laravel.
use TookanTech\Chapaar\SmsChannel; class InvoicePaid extends KavenegarBaseNotification { public function via($notifiable): array { return [SmsChannel::class]; } public function toSms($notifiable) { return (new SmsMessage)->driver() ->setTemplate('verify') ->setTokens([123],[456]) } } class User extends Authenticatable { use Notifiable; public function routeNotificationForSms($driver, $notification = null) { return $this->mobile; } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
tookantech/chapaar 适用场景与选型建议
tookantech/chapaar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 454 次下载、GitHub Stars 达 14, 最近一次更新时间为 2023 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「notification」 「laravel」 「kavenegar」 「Ghasedak」 「smsir」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tookantech/chapaar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tookantech/chapaar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tookantech/chapaar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Simple javascript toast notifications
统计信息
- 总下载量: 454
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-23