PHPackages                             php-channels/discord-webhook - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. php-channels/discord-webhook

ActiveLibrary[HTTP &amp; Networking](/categories/http)

php-channels/discord-webhook
============================

Interface for quick and direct communication with Discord channels via Webhook.

v1.0.6(2y ago)234.6k↓38.3%[1 issues](https://github.com/muriloperosa/discord-webhook/issues)MITPHPPHP &gt;=7.2

Since Feb 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/muriloperosa/discord-webhook)[ Packagist](https://packagist.org/packages/php-channels/discord-webhook)[ RSS](/packages/php-channels-discord-webhook/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

PHP Discord Webhook
===================

[](#php-discord-webhook)

[![php workflow](https://github.com/muriloperosa/discord-webhook/actions/workflows/php.yml/badge.svg)](https://github.com/muriloperosa/discord-webhook/actions/workflows/php.yml/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/84a181a6eb56fc85170b86423365a9eefbcf9b4410d59e3d5c7140492230432b/687474703a2f2f706f7365722e707567782e6f72672f7068702d6368616e6e656c732f646973636f72642d776562686f6f6b2f76)](https://packagist.org/packages/php-channels/discord-webhook) [![Total Downloads](https://camo.githubusercontent.com/3bd2528a216392119952ba2c29cde6d392aca0db4c2faaf7835828a868132764/687474703a2f2f706f7365722e707567782e6f72672f7068702d6368616e6e656c732f646973636f72642d776562686f6f6b2f646f776e6c6f616473)](https://packagist.org/packages/php-channels/discord-webhook) [![License](https://camo.githubusercontent.com/48de76cb25a6775c997205e7148e4e994a1adcf85e4cceb4a99ff3f79f455401/687474703a2f2f706f7365722e707567782e6f72672f7068702d6368616e6e656c732f646973636f72642d776562686f6f6b2f6c6963656e7365)](https://packagist.org/packages/php-channels/discord-webhook) [![PHP Version Require](https://camo.githubusercontent.com/9d36b5cce9e727d0689ce3763d6599e4b1e2c17514ca17f2f552fc36bd85ec7d/687474703a2f2f706f7365722e707567782e6f72672f7068702d6368616e6e656c732f646973636f72642d776562686f6f6b2f726571756972652f706870)](https://packagist.org/packages/php-channels/discord-webhook)

PHP package that contains a set of methods for simple, direct and elegant communication with Discord channels via Webhooks.

Composer
--------

[](#composer)

### Install

[](#install)

```
composer require php-channels/discord-webhook
```

### Update

[](#update)

```
composer update php-channels/discord-webhook
```

QA
--

[](#qa)

### Unit Tests

[](#unit-tests)

To run unit tests using PHPUnit:

```
./vendor/bin/phpunit ./tests
```

### PHP Stan

[](#php-stan)

To run code static analysis using PHP Stan:

```
./vendor/bin/phpstan analyse
```

General
-------

[](#general)

The main goal of this package is to allow highly customizable messages to be sent to Discord channels in a simple and semantic way via Webhooks. The base payload used to build the code can be accessed at [`./documentation/payload.json`](https://github.com/muriloperosa/discord-webhook/blob/main/documentation/payload.json).

### Basic Usage

[](#basic-usage)

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setUsername('My Bot')
    ->setContent('Hello World!')
    ->send();
```

[![image](https://user-images.githubusercontent.com/45050585/218358617-b0c2565b-2ca3-41ed-a25f-e3edae2de885.png)](https://user-images.githubusercontent.com/45050585/218358617-b0c2565b-2ca3-41ed-a25f-e3edae2de885.png)

### 1. Define Webhook

[](#1-define-webhook)

There are two ways which the destination webhook of the message can be defined. The first is to pass the URL of the webhook as parameter to the `message (?string $webhook = null)` method, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path');
// ...
```

Or the webhook can be set via the `setWebhook (string $webhook)` method, as in the second example:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message()
    ->setWebhook('https://discord.com/api/webhooks/your-webhook-path');
// ...
```

### 2. Username

[](#2-username)

The name of the sender of the message can be set using the `setUsername (string $username)` method, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setUsername('Your Name')
    ->setContent('Hello World!')
    ->send();
```

### 3. Avatar

[](#3-avatar)

The avatar of the sender of the message can be set using the `setAvatar (string $avatar_url)` method, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setUsername('My Bot')
    ->setContent('Hello World!')
    ->setAvatar('https://fake-avatar.com/avatar.png')
    ->send();
```

### 4. Content

[](#4-content)

A simple text content of the message can be set using the `setContent (string $content)` method, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setContent('A simple text message you want to send!')
    ->send();
```

### 5. Embeds

[](#5-embeds)

However, the message content can be enriched through the `setEmbeds (array $embeds)` method, which takes an array as a parameter, enabling a wide range of customizations, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setEmbeds(['color' => '123456', 'title' => 'Embed content!'])
    ->send();
```

Working with Embeds
-------------------

[](#working-with-embeds)

Working with embeds content through a single array that fully handles this property is very powerful and can certainly be very useful on many occasions. But it can get really confusing when we are working with a very large array of settings, making it difficult to read and maintain the code. To solve this problem methods for manipulating embeds were added to the package, which are described below.

### 1. Author

[](#1-author)

To handle the `embeds[0]['author']` property, the `setAuthor (string $name, ?string $url = '', ?string $icon_url = '')` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setAuthor('Author Name')
    ->send();

// optional param $url
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setAuthor('Author Name', 'https://fake-author.com')
    ->send();

// optional param $icon_url
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setAuthor('Author Name', 'https://fake-author.com', 'https://fake-icon.com/icon.png')
    ->send();
```

### 2. Title

[](#2-title)

To handle the `embeds[0]['title']` property, the `setTitle (string $title)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setTitle('Your title here!')
    ->send();
```

### 3. URL

[](#3-url)

To handle the `embeds[0]['url']` property, the `setUrl (string $url)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setUrl('https://fake-url.com')
    ->send();
```

### 4. Description

[](#4-description)

To handle the `embeds[0]['description']` property, the `setDescription (string $description)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setDescription('Your description here!')
    ->send();
```

### 5. Color

[](#5-color)

To handle the `embeds[0]['color']` property, the `setColor (string $color)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setColor('2450411')
    ->send();
```

> Note: The color value should be a decimal number. We suggest to use [this converter](https://www.checkyourmath.com/convert/color/hexadecimal_decimal.php) to convert hexadecimal values to decimal.

Or you can use `setColor` method passing a string `reference color`, as in the example below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setColor('info')
    ->send();
```

> The possible color references are: `'info', 'error', 'notice', 'warning', 'success'`.

### 6. Fields

[](#6-fields)

To add fields to `embeds[0]['fields']` property, the `setField (string $name, string $value, bool $inline = null)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setField('Name', 'Value')
    ->send();

// optional param $inline
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setField('Name', 'Value', true)
    ->send();

// multiple fields
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setField('Name 1', 'Value 1')
    ->setField('Name 2', 'Value 2', true)
    ->send();
```

> Note: This method can be invoked several times, each time adding a new field to the array.

### 7. Thumbnail

[](#7-thumbnail)

To add fields to `embeds[0]['thumbnail']` property, the `setThumbnail (string $thumbnail)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setThumbnail('https://fake-thumb.com/thumb.png')
    ->send();
```

### 8. Image

[](#8-image)

To add fields to `embeds[0]['image']` property, the `setImage (string $image)` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setImage('https://fake-image.com/image.png')
    ->send();
```

### 9. Footer

[](#9-footer)

To add fields to `embeds[0]['footer']` property, the `setFooter (string $text,  ?string $icon_url = '')` method can be used, as in the examples below:

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setFooter('Text to footer here!')
    ->send();

// optional param $icon_url
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setFooter('Text to footer here!', 'https://fake-icon.com/icon.png')
    ->send();
```

Usage Example
-------------

[](#usage-example)

```
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
    ->setUsername('Application Bot')
    ->setAvatarUrl('https://fake-avatar.com/avatar.png')
    ->setContent('Content here!')
    ->setColor('2450411')
    ->setTitle('Title here!')
    ->setDescription('Description here!')
    ->send();
```

> Note: The above example is for documentation purposes only, and that all the methods presented in this file can be combined to send the message as you need.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.1% 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 ~71 days

Recently: every ~94 days

Total

7

Last Release

807d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffa16840bdbb95f677ba5ebf374e627a432129f3cc627e6f19efbbb2c0d65b73?d=identicon)[Murilo Perosa](/maintainers/Murilo%20Perosa)

---

Top Contributors

[![muriloperosa](https://avatars.githubusercontent.com/u/45050585?v=4)](https://github.com/muriloperosa "muriloperosa (68 commits)")[![jrfernandodasilva](https://avatars.githubusercontent.com/u/27747005?v=4)](https://github.com/jrfernandodasilva "jrfernandodasilva (18 commits)")

---

Tags

discordlibrarypackagephpwebhookwebhooks

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-channels-discord-webhook/health.svg)

```
[![Health](https://phpackages.com/badges/php-channels-discord-webhook/health.svg)](https://phpackages.com/packages/php-channels-discord-webhook)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[guzzlehttp/guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

25711.0M191](/packages/guzzlehttp-guzzle-services)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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