kwadwokyeremeh/hubtel-laravel-sms
Composer 安装命令:
composer require kwadwokyeremeh/hubtel-laravel-sms
包简介
Hubtel SMS Channel for Laravel ^11|^122
README 文档
README
#Hubtel notification channel for Laravel 11+
This package makes it easy to send notifications using Hubtel with Laravel 11+.
Contents
- Installation
- Usage
- Testing the Integration
- Querying Message Status
- Changelog
- Testing
- Security
- Contributing
- Credits
- License
Installation
To get the latest version of Hubtel Notification channel for Laravel 11+, simply require the project using Composer:
Run from your terminal
$ composer require kwadwokyeremeh/hubtel-laravel-sms
Setting up the Hubtel service
In your Hubtel account go to Applications page. Click on the details of the desired application and copy your apiKey and apiSecret
In your terminal run
$ php artisan vendor:publish --provider="NotificationChannels\Hubtel\HubtelServiceProvider"
This creates a hubtel-sms.php file in your config directory.
Paste your apiCredentials in the config/hubtel.php configuration file. You may copy the example configuration below to get started:
'api_key' => env('HUBTEL_CLIENT_ID'), 'api_secret' => env('HUBTEL_CLIENT_SECRET') 'use_post_method' => env('HUBTEL_SEND_METHOD')
Or
Add the HUBTEL_CLIENT_ID and HUBTEL_CLIENT_SECRET to your .env file
Usage
Now you can use the channel in your via() method inside the notification:
use Illuminate\Notifications\Notification; use NotificationChannels\Hubtel\HubtelChannel; use NotificationChannels\Hubtel\HubtelMessage; class SayHello extends Notification { public function via($notifiable) { return [HubtelChannel::class]; } public function toSMS($notifiable) { return (new HubtelMessage) ->from("JabClari") ->to("2331234567890") ->content("Kim Kippo... Sup with you"); } }
In order to let your Notification know which phone number you are sending to, add the routeNotificationForSMS method to your Notifiable model e.g your User Model
public function routeNotificationForSMS() { return $this->phone; // where phone is a cloumn in your users table; }
Available Message methods
from($from): set the sender's name or phone numberto($to): set the recipient's phone numbercontent($content): set the message contentregisteredDelivery(): set delivery report requestclientReference($reference): set the client reference numbertype($type):set the message type to be sentudh($udh): set the User Data Header of the SMS Message being senttime($time): set the time to deliver the messageflashMessage(): sends the message as a flash message
Read more about the available methods on the Hubtel Documentation Page
Testing the Integration
You can test your Hubtel SMS integration using the built-in Artisan command:
php artisan hubtel-sms:test +1234567890 --from="SenderName" --message="Your test message here"
Command Arguments and Options:
to- Required. The recipient phone number--from- Optional. The sender ID/name (defaults to config value or 'Laravel')--message- Optional. Custom message content (defaults to a standard test message)
Prerequisites:
-
Configure Hubtel API credentials in your
.envfile:HUBTEL_CLIENT_ID=your_client_id HUBTEL_CLIENT_SECRET=your_client_secret -
Publish the config file (if not already done):
php artisan vendor:publish --tag=hubtel-sms-config
Querying Message Status
The package now supports querying the status of sent messages. You can check the delivery status of a message using the HubtelStatusChecker:
use NotificationChannels\Hubtel\SMSClients\HubtelStatusChecker; use GuzzleHttp\Client; $statusChecker = new HubtelStatusChecker($apiKey, $apiSecret, new Client()); $response = $statusChecker->query('message-id-here'); if ($response->isDelivered()) { echo "Message was delivered successfully"; } // Access other status information $response->getStatus(); $response->getUpdateTime();
You can also check message status using the built-in Artisan command:
php artisan hubtel-sms:status message-id-here
This command will display detailed information about the message including delivery status, recipient, content, and delivery time.
Changelog
Latest Notice
For developers who would want to use this package on VPS hosted applications, if the server location is US for which you have a US IP Address, you may need to seek whitelisting of the US Ip address from hubtel by mailing support@hubtel.com. As i discovered through experience that the package would work fine on local machine because the IP used is a Ghanaian IP address but fails to work on a production server. Note however that this is not a package problem, as the package justorganizes components for sending successful SMS messages within Laravel. It is even more challenging to know the cause of the problem when you are using laravel queues, because the response codes are not logged, the queue just logs Processing failed.Hubtels SMS server responds with a 403 Forbidden, when the same SMS issent directly using Guzzlehttp on the production server (VPS). A 403 HTTP Response according to their website (hubtel) indicates the recipient has not given his/her approval to receive messages which is even more confusing. :)
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
To run the live tests, you need to set the required environment variables. Here's how you can do it: First, you need to set the environment variables with your Hubtel API credentials:
export HUBTEL_CLIENT_ID=your-api-key export HUBTEL_CLIENT_SECRET=your-api-secret export RUN_LIVE_TESTS=true export HUBTEL_SEND_METHOD=true // true for POST method, false for GET method export HUBTEL_SENDER_ID=your-sender-id export HUBTEL_PHONE_NUMBER=your-phone-number
Then, run the tests:
vendor/bin/phpunit --group=live --dont-report-useless-tests
Security
If you discover any security related issues, please email norisjibril@gmail.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
kwadwokyeremeh/hubtel-laravel-sms 适用场景与选型建议
kwadwokyeremeh/hubtel-laravel-sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 101 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「laravel」 「hubtel」 「serenity」 「query-sms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kwadwokyeremeh/hubtel-laravel-sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kwadwokyeremeh/hubtel-laravel-sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kwadwokyeremeh/hubtel-laravel-sms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
A Laravel package for consuming the Hubtel Payment Api
yii2-sms expand
Alfabank REST API integration
An unofficial php library for processing Hubtel USSD requests
统计信息
- 总下载量: 101
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-18