elbrahms/wa-gateway
Composer 安装命令:
composer require elbrahms/wa-gateway
包简介
Laravel package for WhatsApp messaging via the Whatsms gateway API
README 文档
README
Laravel package for sending WhatsApp messages through the Whatsms gateway API.
Supports text, media, polls, stickers, buttons, lists, locations, vCards, and device/user management.
Requirements
- PHP ≥ 8.1
- Laravel 11 or 12
- A running Whatsms gateway instance
Installation
composer require elbrahms/wa-gateway
The service provider and facade are registered automatically via Laravel's package discovery.
Publish the config file:
php artisan vendor:publish --tag=wa-gateway-config
Configuration
Add these variables to your .env:
WA_GATEWAY_URL=https://whatsms.fite-ne.com WA_GATEWAY_API_KEY=your_api_key_here WA_GATEWAY_SENDER=22799749554 WA_GATEWAY_TIMEOUT=30 WA_GATEWAY_VERIFY_SSL=true
Usage
Via the Facade
use Elbrahms\WaGateway\Facades\WaGateway; // Send a text message WaGateway::sendMessage('22799123456', 'Hello from Laravel!'); // Send an image WaGateway::sendMedia('22799123456', 'image', 'https://example.com/photo.jpg', 'Check this out!'); // Send a document WaGateway::sendMedia('22799123456', 'document', 'https://example.com/report.pdf'); // Send a poll WaGateway::sendPoll('22799123456', 'Favourite color?', ['Red', 'Blue', 'Green']); // Send a sticker WaGateway::sendSticker('22799123456', 'https://example.com/sticker.webp'); // Send a location WaGateway::sendLocation('22799123456', '13.5137', '2.1098'); // Send a vCard WaGateway::sendVcard('22799123456', 'Ibrahim Sidi', '22799000000'); // Check if a number is on WhatsApp $result = WaGateway::checkNumber('22799123456'); // $result['msg']['exists'] === true
Button Message
WaGateway::sendButton( number: '22799123456', message: 'How can we help?', buttons: [ ['type' => 'reply', 'displayText' => 'Support'], ['type' => 'url', 'displayText' => 'Website', 'url' => 'https://fite-ne.com'], ['type' => 'call', 'displayText' => 'Call us', 'phoneNumber' => '22799749554'], ['type' => 'copy', 'displayText' => 'Copy code', 'copyCode' => 'PROMO2025'], ], footer: 'Powered by WaGateway' );
List Message
WaGateway::sendList( number: '22799123456', message: 'Choose a department', title: 'Our Departments', buttonText: 'View list', list: ['Sales', 'Support', 'Billing', 'Technical'], footer: 'We reply within 24 h' );
Device Management
// Generate QR code to connect a device $qr = WaGateway::generateQr('22799749554'); // $qr['qrcode'] is a base64-encoded PNG — display or save it // Create a new device WaGateway::createDevice('22799000001', 'https://yourapp.com/webhook'); // Get device information $info = WaGateway::deviceInfo('22799749554'); // Disconnect a device WaGateway::disconnectDevice('22799749554');
User Management (admin only)
// Create a user WaGateway::createUser( username: 'newuser', password: 'secret123', email: 'newuser@example.com', expire: 30, limitDevice: 5 ); // Get user info $user = WaGateway::userInfo('newuser');
Dependency Injection
use Elbrahms\WaGateway\WaGateway; class NotificationService { public function __construct(protected WaGateway $wa) {} public function notify(string $phone, string $text): void { $this->wa->sendMessage($phone, $text); } }
Override Sender Per Call
Every method accepts an optional $sender parameter:
WaGateway::sendMessage('22799123456', 'Hello!', sender: '22788868500');
Error Handling
All methods throw Elbrahms\WaGateway\Exceptions\WaGatewayException on failure:
use Elbrahms\WaGateway\Exceptions\WaGatewayException; try { WaGateway::sendMessage('22799123456', 'Hello!'); } catch (WaGatewayException $e) { logger()->error('WaGateway error: ' . $e->getMessage(), $e->getErrors()); }
Webhook Payload
When your device receives a message the gateway will POST to your webhook URL:
{
"device": "22799749554",
"message": "Hello!",
"from": "22799123456",
"name": "Contact Name",
"participant": null,
"ppUrl": "https://...",
"media": null
}
License
The MIT License (MIT). See LICENSE.md.
elbrahms/wa-gateway 适用场景与选型建议
elbrahms/wa-gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「gateway」 「messaging」 「laravel」 「whatsapp」 「whatsms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elbrahms/wa-gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elbrahms/wa-gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elbrahms/wa-gateway 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
PHP SDK for Mobile Message SMS API
Extensible library for building notifications and sending them via different delivery channels.
Azure service bus Transport
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-30