PHPackages                             maina-david/whatsapp-sdk - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. maina-david/whatsapp-sdk

ActiveLibrary[Queues &amp; Workers](/categories/queues)

maina-david/whatsapp-sdk
========================

Integrate Facebook Graph API to WhatsApp

1.1(2y ago)020MITPHPPHP &gt;=8.0

Since Jun 8Pushed 2y ago2 watchersCompare

[ Source](https://github.com/maina-david/whatsapp-sdk-php)[ Packagist](https://packagist.org/packages/maina-david/whatsapp-sdk)[ Docs](https://github.com/maina-david/whatsapp-sdk-php)[ RSS](/packages/maina-david-whatsapp-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

WhatsApp PHP SDK
================

[](#whatsapp-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/e8c9fc5d2edb1894943d75aa1f572cee80feb9346c8673d88ce76e5df10f1496/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61696e612d64617669642f77686174736170702d73646b)](https://packagist.org/packages/maina-david/whatsapp-sdk)

[![WhatsApp](https://camo.githubusercontent.com/0fd81f6966d2b31b91adcd1544003089a49c07b7a6f166c72f2d52aac9e0f0d9/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f576861747341707025323050485025323053444b2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6d61696e612d646176696425324677686174736170702d73646b267061747465726e3d62616d626f6f267374796c653d7374796c655f31266465736372697074696f6e3d412b5048502b7061636b6167652b666f722b696e746567726174696e672b7468652b57686174734170702b627573696e6573732b41504973266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/0fd81f6966d2b31b91adcd1544003089a49c07b7a6f166c72f2d52aac9e0f0d9/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f576861747341707025323050485025323053444b2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6d61696e612d646176696425324677686174736170702d73646b267061747465726e3d62616d626f6f267374796c653d7374796c655f31266465736372697074696f6e3d412b5048502b7061636b6167652b666f722b696e746567726174696e672b7468652b57686174734170702b627573696e6573732b41504973266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

> This SDK provides convenient access to the WhatsApp API for applications written in PHP.

Documentation
-------------

[](#documentation)

Take a look at the [WhatsApp Business Management API docs here](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/).

Install
-------

[](#install)

You can install the PHP SDK via composer or by downloading the source

### Via Composer

[](#via-composer)

The recommended way to install the SDK is with [Composer](http://getcomposer.org/).

```
composer require maina-david/whatsapp-sdk
```

Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

```
'providers' => [
    // ...
    MainaDavid\WhatsAppSDK\WhatsAppServiceProvider::class,
];
```

You should publish the config/whatsapp.php config file with:

```
php artisan vendor:publish --provider="MainaDavid\WhatsAppSDK\WhatsAppServiceProvider"
```

Set up in the config/whatsapp.php: Phone Number ID, permanent access token and Graph API version you want to use(Default is V15.0) obtained from the [Developer's Dashboard](https://developers.facebook.com/).

Usage
-----

[](#usage)

You will need to set up a phone number and a permanent access token in [Facebook Developer's Portal](https://developers.facebook.com/).

[Learn how to create a permanent token](https://developers.facebook.com/docs/whatsapp/business-management-api/get-started#1--acquire-an-access-token-using-a-system-user-or-facebook-login)

### Instantiating the WhatsApp Class

[](#instantiating-the-whatsapp-class)

The `WhatsApp` class can be instantiated with or without parameters. If no parameters are provided, it will attempt to retrieve the values from the whatsapp configuration file. Alternatively, you can pass the necessary parameters directly when instantiating the class.

```
use MainaDavid\WhatsAppSDK\WhatsApp;

public function sendMessage()
{
    try {
        // Instantiate the Whatsapp class with the necessary parameters
        $whatsapp = new WhatsApp($phoneNumberId, $accessToken);

        // Prepare the options for sending a text message
        $options = [
            'to' => '+123456789', // Replace with the recipient's phone number
            'message' => 'Hello, world!' // Replace with the message content
        ];

        // Call the sendTextMessage() method of the Whatsapp class to send the message
        $response = $whatsapp->sendTextMessage($options);

        // Handle the response or perform other actions
        if ($response['status'] === 'success') {
            // Message sent successfully
            return response()->json(['message' => 'Message sent']);
        } else {
            // Failed to send message
            return response()->json(['message' => 'Failed to send message']);
        }
    } catch (Exception $e) {
        // Handle any exceptions that occur during initialization or API calls
        return response()->json(['message' => $e->getMessage()], 500);
    }
}
```

In the above example, the `WhatsApp` class is instantiated using the `$phoneNumberId` and `$accessToken` parameters. You can provide these parameters directly or let the class retrieve them from the configuration file if they are not specified.

Remember to replace `+123456789` with the actual recipient's phone number and `'Hello, world!'` with the desired message content.

Make sure to adjust the namespace and class name (`WhatsApp`) based on your project's structure. Additionally, modify the code inside the `sendMessage()` method to match your specific use case.

### TextMessage

[](#textmessage)

- `sendTextMessage(array $options)`: Sends a text message

    - `message`: Message content. `REQUIRED`
    - `to`: phone number. `REQUIRED`
- `sendReplyToTextMessage(array $options)`: Reply to a message

    - `message_id`: whatsapp message ID of previous message. `REQUIRED`
    - `message`: Message content. `REQUIRED`
    - `to`: phone number. `REQUIRED`
- `sendMediaMessageByURL(array $options)`: Send a media message with url

    - `type`: media type. Only 'image', 'document', 'audio', 'sticker', 'video' `REQUIRED`
    - `url`: URL of the media to be sent. `REQUIRED`
    - `to`: phone number. `REQUIRED`
    - `caption`: Describes the specified image or video. Do not use it with audio, sticker, or document media. `OPTIONAL`
    - `filename`: Describes the filename for the specific document. Use only with document media. `OPTIONAL`
- `sendMediaMessageByID(array $options)`: Send a media message with media ID

    - `type`: media type. Only 'image', 'document', 'audio', 'sticker', 'video' `REQUIRED`
    - `media_id`: Media ID from WhatsApp. `REQUIRED`
    - `to`: phone number. `REQUIRED`
    - `caption`: Describes the specified image or video. Do not use it with audio, sticker, or document media. `OPTIONAL`
    - `filename`: Describes the filename for the specific document. Use only with document media. `OPTIONAL`
- `sendReplyToMediaMessageByURL(array $options)`: Send a reply to a media message by URL

    - `message_id`: whatsapp message ID of previous message. `REQUIRED`
    - `url`: URL of the media to be sent. `REQUIRED`
    - `to`: phone number. `REQUIRED`
- `sendReplyToMediaMessageByID(array $options)`: Send a reply to a media message by ID

    - `message_id`: whatsapp message ID of previous message. `REQUIRED`
    - `media_id`: Media ID from WhatsApp. `REQUIRED`
    - `to`: phone number. `REQUIRED`
- `sendLocationMessage(array $options)`: Send a location message to a recipient

    - `to`: phone number. `REQUIRED`
    - `latitude`: The longitude of the location. `REQUIRED`
    - `longitude`: The latitude of the location. `REQUIRED`
    - `name`: The name of the location. `OPTIONAL`
    - `address`: The address of the location. This field is only displayed if name is present.. `OPTIONAL`
- `sendReplyToLocationMessage(array $options)`: Send a location message to a recipient

    - `message_id`: whatsapp message ID of previous message. `REQUIRED`
    - `to`: phone number. `REQUIRED`
    - `latitude`: The longitude of the location. `REQUIRED`
    - `longitude`: The latitude of the location. `REQUIRED`
    - `name`: The name of the location. `OPTIONAL`
    - `address`: The address of the location. This field is only displayed if name is present.. `OPTIONAL`
- `markMessageAsRead(array $options)`: Mark a message as read

    - `message_id`: whatsapp message ID of previous message. `REQUIRED`

Testing the SDK
---------------

[](#testing-the-sdk)

The SDK uses [PHPUnit](https://phpunit.de/manual/current/en/index.html) as the test runner.

To run available tests, from the root of the project run:

```
# Run tests
phpunit
```

Issues
------

[](#issues)

If you find a bug, please file an issue on [the issue tracker on GitHub](https://github.com/maina-david/whatsapp-sdk-php/issues).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Every ~10 days

Total

2

Last Release

1063d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19209ddb9c7632e99060f83df45438c545e53e00771d8f8ab9e55cba15046c5b?d=identicon)[MainaDavid](/maintainers/MainaDavid)

---

Top Contributors

[![maina-david](https://avatars.githubusercontent.com/u/32592596?v=4)](https://github.com/maina-david "maina-david (51 commits)")

---

Tags

messageapiwhatsapp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maina-david-whatsapp-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/maina-david-whatsapp-sdk/health.svg)](https://phpackages.com/packages/maina-david-whatsapp-sdk)
```

###  Alternatives

[aliyunmq/mq-http-sdk

Aliyun Message Queue(MQ) Http PHP SDK, PHP&gt;=5.5.0

75379.9k14](/packages/aliyunmq-mq-http-sdk)[alchemy/rabbitmq-management-client

RabbitMQ Management Plugin API Client

4242.6k](/packages/alchemy-rabbitmq-management-client)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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