PHPackages                             renzojohnson/discord-api - 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. renzojohnson/discord-api

ActiveLibrary[API Development](/categories/api)

renzojohnson/discord-api
========================

Lightweight PHP wrapper for Discord REST API. Send messages, embeds, and files via webhooks and Bot tokens. Zero dependencies.

v1.0.0(4mo ago)02MITPHPPHP ^8.4

Since Feb 24Pushed 3mo agoCompare

[ Source](https://github.com/renzojohnson/discord-api)[ Packagist](https://packagist.org/packages/renzojohnson/discord-api)[ Docs](https://renzojohnson.com)[ RSS](/packages/renzojohnson-discord-api/feed)WikiDiscussions main Synced today

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

Discord API for PHP
===================

[](#discord-api-for-php)

[![Latest Version](https://camo.githubusercontent.com/a444f3e9a7977dd352cd8f6c02a58185772aca55bf3895920236bed5b5d08138/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656e7a6f6a6f686e736f6e2f646973636f72642d6170692e737667)](https://packagist.org/packages/renzojohnson/discord-api)[![PHP Version](https://camo.githubusercontent.com/963a684851bcaab397c2cfdb5bb038882d4696e6f88b2337e44dd143a835e2ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72656e7a6f6a6f686e736f6e2f646973636f72642d6170692e737667)](https://packagist.org/packages/renzojohnson/discord-api)[![License](https://camo.githubusercontent.com/a3caef5099e09d140fe93bd034da0a9f30c199f8de07a7d999c8b099e4293fa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72656e7a6f6a6f686e736f6e2f646973636f72642d6170692e737667)](https://github.com/renzojohnson/discord-api/blob/main/LICENSE)

Lightweight PHP wrapper for [Discord REST API](https://discord.com/developers/docs/reference) v10. Zero dependencies.

Send messages, rich embeds, and files via webhooks and Bot tokens. Ed25519 interaction signature verification.

**Author:** [Renzo Johnson](https://renzojohnson.com)

Requirements
------------

[](#requirements)

- PHP 8.4+
- ext-curl
- ext-json
- ext-sodium (for interaction verification)

Installation
------------

[](#installation)

```
composer require renzojohnson/discord-api
```

Quick Start
-----------

[](#quick-start)

```
use RenzoJohnson\Discord\Discord;

$discord = new Discord('your-bot-token');

// Send a text message to a channel
$discord->sendMessage('CHANNEL_ID', 'Hello from PHP!');
```

Bot API
-------

[](#bot-api)

### Send Message

[](#send-message)

```
$discord->sendMessage('CHANNEL_ID', 'Hello World');
```

### Send Embed

[](#send-embed)

```
use RenzoJohnson\Discord\Message\Embed;

$embed = (new Embed())
    ->title('Server Alert')
    ->description('CPU usage is critical')
    ->color(0xFF0000)
    ->field('Server', 'web-01', inline: true)
    ->field('CPU', '95%', inline: true)
    ->footer('Monitoring Bot')
    ->timestamp(date('c'));

$discord->sendEmbed('CHANNEL_ID', $embed);

// Embed with text
$discord->sendEmbed('CHANNEL_ID', $embed, content: 'Attention!');
```

### Edit Message

[](#edit-message)

```
$discord->editMessage('CHANNEL_ID', 'MESSAGE_ID', 'Updated content');
```

### Delete Message

[](#delete-message)

```
$discord->deleteMessage('CHANNEL_ID', 'MESSAGE_ID');
```

### Add Reaction

[](#add-reaction)

```
$discord->addReaction('CHANNEL_ID', 'MESSAGE_ID', '👍');
```

### Get Channel / Guild Channels

[](#get-channel--guild-channels)

```
$channel = $discord->getChannel('CHANNEL_ID');
$channels = $discord->getGuildChannels('GUILD_ID');
```

Webhooks
--------

[](#webhooks)

No bot token needed — just a webhook URL.

```
use RenzoJohnson\Discord\Webhook\Webhook;

$webhook = new Webhook('https://discord.com/api/webhooks/ID/TOKEN');

// Simple text
$webhook->send('Deploy complete!');

// Rich embed
use RenzoJohnson\Discord\Message\Embed;

$embed = (new Embed())
    ->title('Deployed v2.1.0')
    ->description('All systems operational')
    ->color(0x00FF00)
    ->footer('CI/CD Pipeline');

$webhook->sendEmbed($embed, content: 'Production deploy finished');
```

### Webhook Message with Overrides

[](#webhook-message-with-overrides)

```
use RenzoJohnson\Discord\Message\WebhookMessage;

$message = new WebhookMessage(
    content: 'Alert!',
    username: 'AlertBot',
    avatarUrl: 'https://example.com/bot.png',
);

$embed = (new Embed())->title('Error')->description('Database connection failed')->color(0xFF0000);
$message->addEmbed($embed);

$webhook->send($message);
```

Embed Builder
-------------

[](#embed-builder)

Fluent API for building rich embeds.

```
$embed = (new Embed())
    ->title('Title')
    ->description('Description text')
    ->url('https://example.com')
    ->color(0x5865F2)              // Discord blurple
    ->author('Bot Name', 'https://example.com', 'https://example.com/icon.png')
    ->thumbnail('https://example.com/thumb.png')
    ->image('https://example.com/image.png')
    ->field('Field 1', 'Value 1', inline: true)
    ->field('Field 2', 'Value 2', inline: true)
    ->footer('Footer text', 'https://example.com/footer-icon.png')
    ->timestamp(date('c'));
```

Interaction Verification (Ed25519)
----------------------------------

[](#interaction-verification-ed25519)

For Discord slash commands and interactions endpoint.

```
use RenzoJohnson\Discord\Webhook\InteractionVerifier;

// Verify signature and get body
$body = InteractionVerifier::verify('YOUR_PUBLIC_KEY');
$interaction = json_decode($body, true);

// Respond to PING
if ($interaction['type'] === 1) {
    InteractionVerifier::respondToPing();
}
```

Error Handling
--------------

[](#error-handling)

```
use RenzoJohnson\Discord\Exception\AuthenticationException;
use RenzoJohnson\Discord\Exception\RateLimitException;
use RenzoJohnson\Discord\Exception\DiscordException;

try {
    $discord->sendMessage('CHANNEL_ID', 'Hello');
} catch (AuthenticationException $e) {
    // Invalid bot token (401)
} catch (RateLimitException $e) {
    $retryAfter = $e->getRetryAfter(); // seconds (float)
} catch (DiscordException $e) {
    // Other API errors
    $errorData = $e->getErrorData();
}
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/renzojohnson/discord-api)
- [GitHub](https://github.com/renzojohnson/discord-api)
- [Issues](https://github.com/renzojohnson/discord-api/issues)
- [Author](https://renzojohnson.com)

License
-------

[](#license)

MIT License. Copyright (c) 2026 [Renzo Johnson](https://renzojohnson.com).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance77

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e1b69733e3d1fd486158d322c23d99281623046b3c357529c9930e50d73fcda?d=identicon)[renzo.johnson](/maintainers/renzo.johnson)

---

Top Contributors

[![renzojohnson](https://avatars.githubusercontent.com/u/4695400?v=4)](https://github.com/renzojohnson "renzojohnson (4 commits)")

---

Tags

discorddiscord-apidiscord-botdiscord-webhookmessagingphpwebhookphpnotificationsmessagingwebhookchatdiscorddiscord-apidiscord-webhookdiscord-bot

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/renzojohnson-discord-api/health.svg)

```
[![Health](https://phpackages.com/badges/renzojohnson-discord-api/health.svg)](https://phpackages.com/packages/renzojohnson-discord-api)
```

###  Alternatives

[prooph/service-bus-symfony-bundle

89394.3k3](/packages/prooph-service-bus-symfony-bundle)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

783.8k](/packages/scriptdevelop-whatsapp-manager)[stymiee/authnetjson

Library that abstracts Authorize.Net's JSON APIs. This includes the Advanced Integration Method (AIM), Automated Recurring Billing (ARB), Customer Information Manager (CIM), Transaction Reporting, Simple Integration Method (SIM), and Webhooks.

19604.4k](/packages/stymiee-authnetjson)

PHPackages © 2026

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