Download the PHP package afro-technology/waha-laravel-sdk without Composer
On this page you can find all versions of the php package afro-technology/waha-laravel-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package waha-laravel-sdk
WAHA Laravel SDK
Laravel-oriented SDK for WAHA (WhatsApp HTTP API / Web WhatsApp gateway).
It provides:
- Multi-host support (primary/secondary, etc.)
- Optional session → host pinning (Redis/DB/composite)
- OpenAPI-driven routing (reads WAHA OpenAPI spec and calls the generated client)
- Convenience DX layer (Facade + tag proxies + top-level aliases)
- IDE autocomplete generation (PHPDoc for Facade/proxies)
- Debug tools:
Waha::lastHttp()/Waha::lastHttpCurl()+ scoped debug
Repository is meant to be installed into Laravel apps via Composer.
Contents
- Installation
- Configuration
- Quick Start
- Usage
- Host selection
- Tag proxies
- Top-level convenience methods
- Response formats
- Debug & last HTTP
- Webhooks
- Endpoint and secret
- Processing mode
- Handlers
- Event storage
- OpenAPI workflow
- IDE Helper
- Testing & CI
- Versioning
- License
Installation
Requirements
- PHP 8.1+ (Laravel 13 requires PHP 8.3+)
- Laravel 10 / 11 / 12 / 13
- Guzzle 7.5+
Composer install
Laravel package discovery is enabled by default.
Publish config (recommended)
This creates config/waha.php.
Configuration
Main config: config/waha.php
Minimal .env
Hosts
Configure one or more hosts under waha.hosts:
Host authentication: admin_api_key vs session_keys
WAHA can be protected either with a single admin key (simplest) or with per-session keys (safer when you want to scope access).
-
admin_api_key: one key for the whole WAHA instance. The SDK sends it asX-Api-Key(orapi_key_header).
Use this for typical server-to-server setups where your application fully trusts itself. -
session_keys: a map ofsession => key. Useful when you run multiple WhatsApp sessions and want to isolate them (e.g., different tenants / orgs) so one leaked key cannot control other sessions. modecontrols how the SDK chooses a key:admin_fallback(default): if a session key exists for the resolved session, use it; otherwise fall back toadmin_api_key.strict_session_key: require a session key for the session; if missing, the request fails instead of silently using the admin key.
⚠️ Note: the OpenAPI-generated client currently authenticates with the host’s admin_api_key (because the generator config supports one API key).
Per-session keys are used by the internal WahaHttpClient / ApiKeyProvider layer (useful for custom calls and for future extensions).
Debug
- Last call capture (
lastHttp/lastHttpCurl) is stored regardless of logging. - When
WAHA_DEBUG=true, requests/responses are also logged (masked + truncated).
Registry, routing, and pin store (multi-host / “session → host” mapping)
This SDK can work in a simple single-host setup (no routing), but it also supports multi-host deployments where a session must consistently “stick” to the same WAHA host.
These three config blocks control that behavior:
registry
Where host definitions come from.
registry.driver=config(default): hosts are read fromconfig/waha.php(waha.hosts.*).registry.driver=db: hosts are stored in package tables (publish + run migrations). Use this if you want to manage hosts from an admin UI or the database.registry.driver=custom: hosts and keys are resolved through your own Laravel services implementingHostRegistryand, optionally,ApiKeyProvider. Use this when the host registry lives in your app, for example encrypted tenant or admin-panel storage.
If WAHA_API_KEY_PROVIDER is omitted, the SDK reads admin and session keys from the host arrays returned by your custom HostRegistry.
routing
How the SDK chooses a host when you call methods without explicitly selecting one.
routing.driver=none(default): no automatic routing. You callWaha::host('primary')...or rely onwaha.default_host.routing.driver=pin: resolves session → host using the pin store. This is the recommended mode if you run multiple WAHA nodes and want stable routing.
pin_store
Where session → host mappings are stored (used by routing.driver=pin).
pin_store.driver=auto(default): preferscompositewhen possible, else falls back toredis, elsedb.pin_store.driver=composite: write-through redis + db, read redis-first then db (best of both worlds).pin_store.driver=redis: fastest, but you may lose mappings if redis is cleared (unless you persist it).pin_store.driver=db: durable, but slower.
Other knobs:
pin_store.ttl_seconds: optional TTL for mappings (0= no TTL).pin_store.redis_connection: which Laravel redis connection to use.
Typical setup for production multi-host:
routing.driver=pinpin_store.driver=composite(orauto)- redis enabled + migrations applied
Response format
model: generated OpenAPI model objects (default)array: normalized PHP arraysjson: normalized array thenjson_encode
Quick Start
Equivalent via tag proxy (tag names come from the OpenAPI spec):
Usage
Host selection
If you don’t call host(), waha.default_host is used.
Tag proxies
Tags are exposed as methods (normalized to lowerCamel). Example:
Top-level convenience methods
Some operations are also exposed at the top level (only when their aliases are unique globally):
If an alias is not available at the top level (collision), use the tag:
Response formats
Global via .env (WAHA_RESPONSE_FORMAT) or per chain:
Works with tag proxies too:
Debug & last HTTP
Read the last captured request/response:
Enable debug only for the next call:
Scoped debug:
Webhooks
WAHA can deliver inbound events (messages, status updates, etc.) to your Laravel app via HTTP webhooks.
Endpoint and secret
When waha.webhooks.enabled is true, the package registers this route:
The route is stateless and uses the configured host key to resolve the webhook secret:
Configure the same secret in WAHA. The package verifies WAHA webhook HMAC headers before dispatching events, handlers, jobs, or storage.
Expected WAHA headers:
X-Webhook-HmacX-Webhook-Hmac-AlgorithmX-Webhook-Request-IdX-Webhook-Timestamp
Processing mode
The default processing mode is sync so a fresh install works without a queue worker:
For production, prefer queue mode so WAHA is acknowledged quickly and your application work happens inside Laravel workers:
Queue mode validates the request, optionally stores an inbox event, dispatches ProcessWahaWebhookJob, and returns JSON immediately. Sync mode runs handlers inside the HTTP request and can make WAHA wait for application-level work.
Handlers
Map WAHA event names to handler classes in config/waha.php:
Handlers must implement:
Event storage
Event storage is disabled by default. To enable it, publish and run the package migrations first:
Then enable storage:
Stored events include payload metadata plus processing state such as queued, processing, processed, failed, attempt count, timestamps, and last error. Use Laravel's normal queue retry tools for retries.
Security note: treat webhook payloads as untrusted input. The package verifies accepted requests before processing.
OpenAPI workflow
This SDK uses WAHA’s OpenAPI spec to route calls and generate the underlying client.
Generated client classes are namespaced under AfroTechnology\Waha\Generated, and
the documented facade/tag examples only use methods exposed by the packaged proxy
surface.
Common commands inside a consuming Laravel application (provided by this package):
-
Fetch spec:
-
Generate OpenAPI client (uses configured generator driver):
- Update (fetch + generate + ide helper, depending on your setup):
Configuration lives under config/waha.php → openapi.
For this package repository and the scheduled GitHub Actions sync, the package-local
entrypoint is php bin/openapi-sync.php; it fetches the spec, regenerates the
client/proxy surface with the package namespace, and leaves the diff for review.
IDE Helper
This package can generate PHPDoc for:
- Facade (
Waha) - Proxies (host chain, tag proxies, top-level operations)
Run:
Then re-index your IDE if autocompletion does not update.
Testing & CI
Local tests:
Recommended additions for public repos:
- Pint (formatting)
- PHPStan (static analysis)
- GitHub Actions workflow running:
composer installcomposer testvendor/bin/pint --testvendor/bin/phpstan analyse
(Exact setup depends on your repo preferences.)
Versioning
Use SemVer:
MAJOR: breaking API changesMINOR: backward-compatible featuresPATCH: backward-compatible fixes
Tags are important for Packagist and for stable dependency resolution.
License
MIT
All versions of waha-laravel-sdk with dependencies
guzzlehttp/guzzle Version ^7.5
illuminate/support Version ^10.0 || ^11.0 || ^12.0 || ^13.0