zapwize/laravel
Composer 安装命令:
composer require zapwize/laravel
包简介
Laravel package for Zapwize WhatsApp Web API integration
README 文档
README
This package provides a simple and expressive way to interact with the Zapwize WhatsApp Web API in your Laravel applications. Send text messages, images, videos, documents, and more with ease.
Features
- Fluent and easy-to-use API
- Send various message types: text, image, video, audio, document, location, contact, poll
- Asynchronous message sending using Laravel Queues
- Webhook handling for incoming messages and status updates
- Secure webhook signature verification
- Automatic caching of server information for better performance
- Configurable logging and connection settings
Installation
You can install the package via composer:
composer require zapwize/laravel
Configuration
-
Publish the configuration file:
php artisan vendor:publish --provider="Zapwize\Laravel\ZapwizeServiceProvider" --tag="config"
This will create a
config/zapwize.phpfile in your application. -
Add the following environment variables to your
.envfile:ZAPWIZE_API_KEY=your_zapwize_api_key # Optional queue settings ZAPWIZE_QUEUE_CONNECTION=database ZAPWIZE_QUEUE=zapwize
Requirements
- PHP 8.2 or higher
- Laravel 9, 10, 11 or 12
Usage
You can use the Zapwize facade to access the client methods.
Sending Messages
Text Message
use Zapwize\Laravel\Facades\Zapwize; $response = Zapwize::sendMessage('1234567890', 'Hello from Laravel!');
Image Message
use Zapwize\Laravel\Facades\Zapwize; $media = [ 'url' => 'https://example.com/image.jpg', // or 'base64' => 'data:image/jpeg;base64,...' ]; $options = [ 'caption' => 'This is a caption.', ]; $response = Zapwize::sendImage('1234567890', $media, $options);
Video Message
use Zapwize\Laravel\Facades\Zapwize; $media = [ 'url' => 'https://example.com/video.mp4', ]; $options = [ 'caption' => 'This is a video.', 'gif' => false, // Set to true for GIF videos ]; $response = Zapwize::sendVideo('1234567890', $media, $options);
Audio Message
use Zapwize\Laravel\Facades\Zapwize; $media = [ 'url' => 'https://example.com/audio.mp3', ]; $response = Zapwize::sendAudio('1234567890', $media);
Document Message
use Zapwize\Laravel\Facades\Zapwize; $media = [ 'url' => 'https://example.com/document.pdf', 'filename' => 'MyDocument.pdf', ]; $response = Zapwize::sendDocument('1234567890', $media);
Location Message
use Zapwize\Laravel\Facades\Zapwize; $response = Zapwize::sendLocation('1234567890', 37.7749, -122.4194);
Contact Message
use Zapwize\Laravel\Facades\Zapwize; $contact = [ 'name' => 'John Doe', 'phone' => '0987654321', ]; $response = Zapwize::sendContact('1234567890', $contact);
Poll Message
use Zapwize\Laravel\Facades\Zapwize; $poll = [ 'name' => 'What is your favorite color?', 'options' => ['Red', 'Green', 'Blue'], 'selectableCount' => 1, ]; $response = Zapwize::sendPoll('1234567890', $poll);
Asynchronous Sending
To send messages without blocking the main thread, you can use the sendMessageAsync method. Make sure your Laravel Queue is configured correctly.
use Zapwize\Laravel\Facades\Zapwize; Zapwize::sendMessageAsync('1234567890', 'This message is sent asynchronously.');
Webhooks
To handle incoming messages and status updates, you need to set up a webhook.
-
In your
config/zapwize.php, setwebhook.enabledtotrueand configure thewebhook.urlandwebhook.secret. -
The package automatically registers the webhook route at
/zapwize/webhook. You can customize this in the config file. -
Listen for the
Zapwize\Laravel\Events\MessageReceivedevent to process incoming messages:In your
EventServiceProvider.php:protected $listen = [ \Zapwize\Laravel\Events\MessageReceived::class => [ \App\Listeners\ProcessIncomingWhatsAppMessage::class, ], ];
Create the listener:
namespace App\Listeners; use Zapwize\Laravel\Events\MessageReceived; class ProcessIncomingWhatsAppMessage { public function handle(MessageReceived $event) { $messageData = $event->message; // Process the incoming message... } }
Other Methods
Check if a number is a WhatsApp number
use Zapwize\Laravel\Facades\Zapwize; $isWhatsAppNumber = Zapwize::isWhatsAppNumber('1234567890');
Get Server Information
use Zapwize\Laravel\Facades\Zapwize; $serverInfo = Zapwize::getServerInfo();
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.
zapwize/laravel 适用场景与选型建议
zapwize/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「messaging」 「laravel」 「whatsapp」 「webhook」 「zapwize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zapwize/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zapwize/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zapwize/laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
PHP SDK for Mobile Message SMS API
Azure service bus Transport
Official PHP client for NATS messaging system
Alfabank REST API integration
Laravel / Lumen package for Firebase Cloud Messaging
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-14