Download the PHP package jordanmiguel/laravel-whatsapp-wuz without Composer
On this page you can find all versions of the php package jordanmiguel/laravel-whatsapp-wuz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jordanmiguel/laravel-whatsapp-wuz
More information about jordanmiguel/laravel-whatsapp-wuz
Files in jordanmiguel/laravel-whatsapp-wuz
Package laravel-whatsapp-wuz
Short Description Laravel package for WhatsApp device management via WuzAPI with multi-owner support
License MIT
Homepage https://github.com/jordanmiguel/laravel-whatsapp-wuz
Informations about the package laravel-whatsapp-wuz
Laravel WhatsApp Wuz
A Laravel package for managing WhatsApp devices through WuzAPI. Connect multiple WhatsApp numbers to your application with multi-owner, multi-device support, Laravel notifications, and automatic webhook handling.
Table of Contents
- Requirements
- Installation
- Configuration
- Quick Start
- Core Concepts
- Usage
- Notification Channel
- Webhooks & Events
- Multi-Device Management
- Facade
- Testing
- License
Requirements
- PHP 8.2+
- Laravel 11 or 12
- A running WuzAPI instance
Installation
Publish the config and migrations, then run them:
Configuration
Add these variables to your .env file:
| Variable | Description |
|---|---|
WUZ_ENABLED |
Enable or disable the package globally |
WUZ_API_URL |
URL of your WuzAPI instance |
WUZ_ADMIN_TOKEN |
Admin token for managing devices via the WuzAPI |
WUZ_DEFAULT_COUNTRY_CODE |
Default country code for phone number normalization |
WUZ_DEBUG |
Enable debug mode — redirects or skips all outgoing messages |
WUZ_DEBUG_TO |
Phone number to redirect all messages to (leave empty to log-only) |
See config/wuz.php for additional options like custom table names, webhook path, and middleware.
Debug Mode
When WUZ_DEBUG=true, all outgoing messages are intercepted before sending. This lets you test the full pipeline in development/staging without messaging real users.
- With
WUZ_DEBUG_TOset: All messages are redirected to that phone number, going through the same validation and sending pipeline. - With
WUZ_DEBUG_TOempty: Messages are logged viaLog::info()and skipped entirely — no API call, no database record.
Quick Start
1. Add the trait and interface to your owner model (any Eloquent model that owns WhatsApp devices):
2. Create a device:
3. Get the QR code and scan it with WhatsApp:
4. Send a message:
Core Concepts
Owners & Devices
Any Eloquent model can own WhatsApp devices by implementing the HasWuzDevices interface. This uses a polymorphic relationship, so a Clinic, Organization, Team, or User model can all own devices independently.
Each owner can have multiple devices. One device per owner is always marked as the default — this is the device used when sending notifications.
Device Lifecycle
- Create — Registers a new device with WuzAPI and stores it in your database
- Connect — Initiates the connection (happens automatically on create)
- Scan QR — Use
GetDeviceStatusActionto retrieve the QR code for the user to scan with their WhatsApp mobile app - Connected — Once scanned, the device is connected and ready to send/receive messages
- Send/Receive — Send messages via
SendMessageAction, receive via webhooks
Usage
Managing Devices
Create a Device
The first device per owner is automatically set as default.
Check Device Status / Get QR Code
Disconnect a Device
Delete a Device
When you delete the default device, the next oldest device is automatically promoted to default.
Sending Messages
Supported message types: text, image, video, document, button.
Notification Channel
Send WhatsApp messages through Laravel's notification system.
Define a Notification
Set Up the Notifiable Model
The notifiable model needs the InteractsWithWuz trait to resolve which device should send the message:
The channel resolves the device by calling resolveWuzOwner() on the notifiable, then uses that owner's default device to send the message.
Configuration — Selective Logging and Event-Driven Messages
config/wuz.php exposes two knobs for the webhook pipeline:
Defaults are conservative. MESSAGE is not logged by default — opt in if you want raw payload rows. Lifecycle, pairing, and error events are logged so you have a forensic trail when things break.
Inbound messages are event-driven. Subscribe to JordanMiguel\Wuz\Events\MessageReceived and persist however your domain needs:
MessageSent fires symmetrically for outbound (HTTP 2xx WUZ responses only).
For media: call WuzService::downloadImage/downloadVideo/downloadDocument from inside a MessageReceived listener. The package no longer auto-downloads.
See UPGRADING.md for the v1→v2 migration guide.
Webhooks & Events
Incoming WhatsApp events are received at POST /api/wuz/webhook/{token} (configurable in config/wuz.php).
Handled Events
| Webhook Event | What Happens | Event Dispatched |
|---|---|---|
| Message | Parses the payload and dispatches the typed event | MessageReceived |
| Disconnected | Updates the device's connected state | DeviceDisconnected |
| LoggedOut | Clears the device's JID and marks as disconnected | DeviceDisconnected |
Logging and WebhookReceived dispatch are gated independently — both default sets are conservative but distinct (notably, MESSAGE dispatches by default but is not logged by default). See the "Configuration — Selective Logging and Event-Driven Messages" section above.
Listening to Events
Register listeners in your EventServiceProvider or use Laravel's event discovery:
Multi-Device Management
Each owner can have multiple WhatsApp devices. The package enforces that exactly one device per owner is the default.
| Rule | Behavior |
|---|---|
| Multiple devices per owner | Supported via polymorphic relationship |
| One default per owner | Enforced via is_default flag |
| First device auto-default | Handled by StoreDeviceAction |
| Delete promotes next | Handled by DeleteDeviceAction |
| Explicit switch | $owner->setDefaultWuzDevice($device) |
| Notification routing | WuzChannel uses the owner's default device |
Facade
Testing
Mock the WuzAPI in your application tests using Laravel's HTTP fakes:
Run the package tests:
License
MIT
All versions of laravel-whatsapp-wuz with dependencies
illuminate/contracts Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-data Version ^4.0