承接 tawhub/laravel-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tawhub/laravel-sdk

Composer 安装命令:

composer require tawhub/laravel-sdk

包简介

Laravel package for TawHub WhatsApp API

README 文档

README

Laravel package to send WhatsApp messages through TawHub API.

Features

  • Send plain text messages
  • Send text messages with file URL
  • Send template messages with dynamic variables
  • Works via Facade or Dependency Injection
  • Input validation for phone number and file extension
  • Configurable retries/backoff and request logging

Installation

composer require tawhub/laravel-sdk

Publish package config:

php artisan vendor:publish --tag=tawhub-config

Configuration

Set values in .env:

TAWHUB_BASE_URL=https://tawhub.com/api/create-message
TAWHUB_APP_KEY=your_app_key
TAWHUB_AUTH_KEY=your_auth_key
TAWHUB_SANDBOX=false
TAWHUB_TIMEOUT=30
TAWHUB_RETRY_TIMES=2
TAWHUB_RETRY_SLEEP_MS=250
TAWHUB_RETRY_BACKOFF=fixed
TAWHUB_LOGGING_ENABLED=false
TAWHUB_LOG_CHANNEL=stack
TAWHUB_LOG_INCLUDE_PAYLOAD=false

Config file: config/tawhub.php

Retry and Logging

  • TAWHUB_RETRY_TIMES: number of retries after first failed attempt.
  • TAWHUB_RETRY_SLEEP_MS: delay in milliseconds before retry.
  • TAWHUB_RETRY_BACKOFF: fixed or exponential.
  • TAWHUB_LOGGING_ENABLED: enable request lifecycle logs.
  • TAWHUB_LOG_CHANNEL: log channel name from Laravel logging config.
  • TAWHUB_LOG_INCLUDE_PAYLOAD: include masked payload in logs.

Usage

1) Text Message

use Tawhub\Laravel\Facades\Tawhub;

$response = Tawhub::send_text('201001112223', 'Welcome from Laravel');

2) Text Message + File

$response = Tawhub::send_text_with_file(
    '201001112223',
    'Invoice attached',
    'https://example.com/invoice.pdf'
);

3) Template Message

$response = Tawhub::send_template('201001112223', 'WELCOME_01', [
    'name' => 'Essam',
    'order_id' => '5566',
]);

4) Dependency Injection (recommended)

use Tawhub\Laravel\Contracts\TawhubClientInterface;

public function send(TawhubClientInterface $tawhub): void
{
    $tawhub->send_text('201001112223', 'Hello!');
}

API Response Example

{
  "message_status": "Success",
  "data": {
    "from": "SENDER_NUMBER",
    "to": "RECEIVER_NUMBER",
    "status_code": 200
  }
}

Error Handling

The package throws:

  • Tawhub\\Laravel\\Exceptions\\InvalidPayloadException
  • Tawhub\\Laravel\\Exceptions\\RequestFailedException

Example:

try {
    $response = Tawhub::send_text('201001112223', 'Hello');
} catch (\Tawhub\Laravel\Exceptions\TawhubException $exception) {
    report($exception);
}

Testing

composer install
composer test

Laravel App Integration Example

Ready-to-copy sample is available in examples/laravel-integration/:

  • examples/laravel-integration/app/Http/Controllers/TawhubDemoController.php
  • examples/laravel-integration/app/Jobs/SendTawhubMessageJob.php
  • examples/laravel-integration/routes/web.php

The flow validates request input in the controller, dispatches a queue job, then sends text/template/file message based on payload.

Release

  • Current release: v1.0.0
  • Changelog: CHANGELOG.md

Notes

  • to must be full WhatsApp number with country code, digits only.
  • Allowed file extensions: jpg, jpeg, png, webp, pdf, docx, xlsx, csv, txt.
  • sandbox is sent as true or false string to match TawHub API examples.

tawhub/laravel-sdk 适用场景与选型建议

tawhub/laravel-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tawhub/laravel-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tawhub/laravel-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 tawhub/laravel-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-11