PHPackages                             emam/whatsapp-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. emam/whatsapp-manager

ActiveLibrary[API Development](/categories/api)

emam/whatsapp-manager
=====================

A framework-agnostic PHP package for WhatsApp integration. Supports multiple drivers (Official Meta, Textly, Ultramsg, WaPilot), dynamic configuration, webhooks, and unified messaging API.

v1.0.0(5mo ago)10MITPHPPHP ^8.1

Since Nov 29Pushed 5mo agoCompare

[ Source](https://github.com/hamada-emam-tech/whatsapp-manager)[ Packagist](https://packagist.org/packages/emam/whatsapp-manager)[ RSS](/packages/emam-whatsapp-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

WhatsApp Manager Package 🚀
==========================

[](#whatsapp-manager-package-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7a8c2e91f6750989ec3bec8fb9c322cfd19ef2613cb9174b1a2aff71e4c4c97d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d616d2f77686174736170702d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emam/whatsapp-manager)[![Total Downloads](https://camo.githubusercontent.com/7f5060796a87e2a5bf26d370ec985281ff88987e3934500adbf7acc75c361789/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d616d2f77686174736170702d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emam/whatsapp-manager)[![License](https://camo.githubusercontent.com/fea8de9f4002f27b9ad4d8c6cc7c7a593709073d5fab31a80bd8e35f10263c01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656d616d2f77686174736170702d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emam/whatsapp-manager)[![Tests](https://github.com/emam/whatsapp-manager/actions/workflows/tests.yml/badge.svg)](https://github.com/emam/whatsapp-manager/actions)

A robust, framework-agnostic PHP package for integrating WhatsApp Business API into your applications. It supports multiple drivers, dynamic configuration, webhooks, and a unified messaging API.

🌟 Features
----------

[](#-features)

- **Multi-Driver Support**:
    - ✅ **Official Meta WhatsApp Business API**
    - ✅ **Textly**
    - ✅ **Ultramsg**
    - ✅ **WaPilot**
    - 🔌 **Custom Drivers**: Easily extendable
- **Unified API**: Send messages using a consistent interface regardless of the driver.
- **Dynamic Configuration**: Load config from arrays, JSON, or environment variables.
- **Webhook Handling**: Secure validation (HMAC signature) and processing of incoming messages.
- **Publishing System**: Publish config and drivers to your project for customization.
- **Framework Agnostic**: Works with Laravel, Symfony, CodeIgniter, or native PHP.
- **Type Safe**: Strict types and comprehensive error handling.

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require emam/whatsapp-manager
```

⚙️ Configuration
----------------

[](#️-configuration)

### 1. Publish Configuration

[](#1-publish-configuration)

Run the publishing command to create a configuration file in your project:

```
php vendor/bin/publish.php config
```

This creates `config/whatsapp.php`.

### 2. Set Environment Variables

[](#2-set-environment-variables)

Add your credentials to your `.env` file:

```
WHATSAPP_DRIVER=official

# Official Meta Driver
WHATSAPP_OFFICIAL_TOKEN=your_access_token
WHATSAPP_OFFICIAL_PHONE_ID=your_phone_number_id
WHATSAPP_OFFICIAL_VERIFY_TOKEN=your_verify_token
WHATSAPP_OFFICIAL_APP_SECRET=your_app_secret

# Textly Driver
WHATSAPP_TEXTLY_TOKEN=your_token

# Ultramsg Driver
WHATSAPP_ULTRAMSG_ID=your_instance_id
WHATSAPP_ULTRAMSG_TOKEN=your_token

# WaPilot Driver
WHATSAPP_WAPILOT_ID=your_instance_id
WHATSAPP_WAPILOT_TOKEN=your_token
```

🚀 Usage
-------

[](#-usage)

### Sending Messages

[](#sending-messages)

```
use Emam\WhatsappManager\Config\ConfigManager;
use Emam\WhatsappManager\WhatsappManager;
use Emam\WhatsappManager\Messages\WhatsappMessage;

// 1. Load Configuration
$config = new ConfigManager(require 'config/whatsapp.php');

// 2. Create Manager
$manager = new WhatsappManager($config->all());

// 3. Send Text Message
$response = $manager->driver()->send('+1234567890',
    WhatsappMessage::create('Hello from WhatsApp Manager!')
);

// 4. Send Media Message (Image)
$message = WhatsappMessage::create()
    ->image('https://example.com/image.png', 'Check this out!');
$manager->driver()->send('+1234567890', $message);

// 5. Send Location
$message = WhatsappMessage::create()
    ->location(25.2048, 55.2708, 'Burj Khalifa', '1 Sheikh Mohammed bin Rashid Blvd');
$manager->driver()->send('+1234567890', $message);

// 6. Upload Media & Send
$driver = $manager->driver('official');
$upload = $driver->uploadMedia('/path/to/image.jpg', 'image');
$mediaId = $upload['id'];

$message = WhatsappMessage::create()
    ->image($mediaId, 'Uploaded image');
$driver->send('+1234567890', $message);

// 7. Reply to Message
$message = WhatsappMessage::create('This is a reply')
    ->reply('wamid.HBg...');
$manager->driver()->send('+1234567890', $message);

// 8. Send Template Message (Official Driver)
$message = WhatsappMessage::create()
    ->template('hello_world', 'en_US');

$manager->driver('official')->send('+1234567890', $message);

// 9. Send Interactive Button Message
$manager->sendButtonMessage('123456')
    ->to('+1234567890')
    ->withBody('Do you confirm your appointment for tomorrow at 3 PM?')
    ->addButton('confirm', '✅ Confirm')
    ->addButton('reschedule', '🔄 Reschedule')
    ->addButton('cancel', '❌ Cancel')
    ->withFooter('Please select an option')
    ->send();

// 10. Send Interactive List Message
$manager->sendListMessage('123456')
    ->to('+1234567890')
    ->withButtonText('View Products')
    ->withBody('Our featured products:')
    ->withHeader('Digital Catalog')
    ->startSection('Laptops')
        ->addRow('laptop-pro', 'MacBook Pro', '16" - 32GB RAM - 1TB SSD')
        ->addRow('laptop-air', 'MacBook Air', '13" - M2 Chip - 8GB RAM')
    ->endSection()
    ->startSection('Smartphones')
        ->addRow('iphone-15', 'iPhone 15 Pro', '48MP Camera - 5G')
        ->addRow('samsung-s23', 'Samsung S23', '120Hz AMOLED Display')
    ->endSection()
    ->send();
```

🛠️ Advanced Usage
-----------------

[](#️-advanced-usage)

### Template Management

[](#template-management)

```
// Get all templates
$templates = $manager->driver('official')->getTemplates(100);

// Create a template
$template = $manager->driver('official')->createTemplate(
    'order_confirmation',
    'UTILITY',
    'en_US',
    [
        ['type' => 'BODY', 'text' => 'Your order {{1}} has been confirmed.']
    ]
);

// Delete a template
$manager->driver('official')->deleteTemplate('order_confirmation');
```

### Template Builder (Fluent API)

[](#template-builder-fluent-api)

```
use Emam\WhatsappManager\Templates\TemplateBuilder;

$driver = $manager->driver('official');

// Create a complete template with fluent API
$template = TemplateBuilder::create($driver)
    ->utility()
    ->name('order_confirmation')
    ->language('en_US')
    ->header('Order Confirmed', 'text')
    ->body('Your order {{1}} has been confirmed. Delivery: {{2}}')
    ->footer('Thank you for your order!')
    ->quickReplyButton('Track Order')
    ->quickReplyButton('Contact Support')
    ->build();

// Marketing template with image
$template = TemplateBuilder::create($driver)
    ->marketing()
    ->name('summer_sale')
    ->language('en_US')
    ->header('', 'image')  // Image header
    ->body('Summer Sale! Get {{1}}% off. Use code: {{2}}')
    ->footer('Valid until end of month')
    ->urlButton('Shop Now', 'https://example.com/sale')
    ->build();
```

### Handling Webhooks

[](#handling-webhooks)

The package provides a secure `WebhookValidator` to handle incoming webhooks.

**Native PHP Example:**

```
use Emam\WhatsappManager\Webhook\WebhookValidator;

$validator = new WebhookValidator($config->all());

try {
    // Validate request
    $validator->validate(
        $_SERVER['REQUEST_URI'],
        $_GET,
        json_decode(file_get_contents('php://input'), true),
        getallheaders()
    );

    // Process webhook
    $payload = json_decode(file_get_contents('php://input'), true);
    $result = $manager->driver()->handleWebhook($payload);

} catch (WebhookException $e) {
    http_response_code(403);
    echo $e->getMessage();
}
```

🛠️ Advanced Usage
-----------------

[](#️-advanced-usage-1)

### Custom Drivers

[](#custom-drivers)

You can easily add your own driver:

```
use Emam\WhatsappManager\Contracts\Driver;

class MyCustomDriver implements Driver {
    // Implement methods...
}

$manager->extend('custom', function() {
    return new MyCustomDriver();
});

$manager->driver('custom')->send(...);
```

### Publishing Drivers

[](#publishing-drivers)

You can publish driver files to your project to modify them:

```
php vendor/bin/publish.php driver Official
```

This creates `app/WhatsApp/Drivers/OfficialDriver.php` which you can customize.

🧪 Testing
---------

[](#-testing)

Run the test suite:

```
composer test
```

🔌 Adding Custom Drivers
-----------------------

[](#-adding-custom-drivers)

The package provides a **complete scaffolding system** to easily add new WhatsApp providers:

### Quick Start

[](#quick-start)

```
# Generate a new driver scaffold
php bin/generate-driver.php ProviderName

# This creates:
# - src/Drivers/ProviderNameDriver.php (driver class)
# - tests/Unit/ProviderNameDriverTest.php (test file)
# - Step-by-step integration instructions
```

### What You Get

[](#what-you-get)

- ✅ **Complete driver template** with all required methods
- ✅ **Pre-configured tests** ready to run
- ✅ **Step-by-step instructions** for integration
- ✅ **Best practices** built-in
- ✅ **Type-safe** implementation

### Example: Adding a New Provider

[](#example-adding-a-new-provider)

```
# 1. Generate scaffold
php bin/generate-driver.php Twilio

# 2. Implement provider-specific logic
# Edit: src/Drivers/TwilioDriver.php

# 3. Run tests
php vendor/bin/pest tests/Unit/TwilioDriverTest.php

# 4. Use your driver
$manager->driver('twilio')->send('+1234567890', $message);
```

### Documentation

[](#documentation)

- 📖 [Complete Driver Development Guide](docs/ADDING_NEW_DRIVER.md)
- ✅ [Driver Development Checklist](docs/DRIVER_CHECKLIST.md)
- 🔧 [Driver Generator Tool](bin/generate-driver.php)

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance72

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f094a4b9f54842ae8f6cd308d2774607737642cddaf9db90bda5adc0b8bf6b9?d=identicon)[hamada-emam-tech](/maintainers/hamada-emam-tech)

---

Top Contributors

[![hamada-emam-tech](https://avatars.githubusercontent.com/u/95125518?v=4)](https://github.com/hamada-emam-tech "hamada-emam-tech (2 commits)")

---

Tags

phpapisdkbusinessmanagerdrivermessagingwhatsappmetaframework agnostic

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/emam-whatsapp-manager/health.svg)

```
[![Health](https://phpackages.com/badges/emam-whatsapp-manager/health.svg)](https://phpackages.com/packages/emam-whatsapp-manager)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
