PHPackages                             larafystudios/discord-webhooks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. larafystudios/discord-webhooks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

larafystudios/discord-webhooks
==============================

A simple, elegant Laravel package for sending Discord webhook messages with support for text content, embeds, and rich formatting.

01PHP

Since Jan 22Pushed 3mo agoCompare

[ Source](https://github.com/LarafyStudios/discord-webhooks)[ Packagist](https://packagist.org/packages/larafystudios/discord-webhooks)[ RSS](/packages/larafystudios-discord-webhooks/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Discord Webhooks for Laravel
============================

[](#discord-webhooks-for-laravel)

A simple, elegant, and feature-rich Laravel package for sending Discord webhook messages with support for text content, embeds, and rich formatting.

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.x or 12.x

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

[](#installation)

Install the package via Composer:

```
composer require larafystudios/discord-webhooks
```

The package will automatically register its service provider and facade.

Configuration
-------------

[](#configuration)

### Publish Configuration (Optional)

[](#publish-configuration-optional)

If you want to customize the default configuration, publish the config file:

```
php artisan vendor:publish --tag=discord-webhooks-config
```

This will create a `config/discord-webhooks.php` file in your project.

### Environment Variables

[](#environment-variables)

You can configure the package using environment variables in your `.env` file:

```
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-url
DISCORD_WEBHOOK_USERNAME="Laravel Application"
DISCORD_WEBHOOK_AVATAR_URL=https://example.com/avatar.png
```

Usage
-----

[](#usage)

### Basic Text Message

[](#basic-text-message)

Send a simple text message:

```
use LarafyStudios\DiscordWebhooks\DiscordWebhook;

DiscordWebhook::make()
    ->setContent('Hello from Laravel!')
    ->send();
```

### Using the Facade

[](#using-the-facade)

You can also use the provided facade:

```
use DiscordWebhook;

DiscordWebhook::make()
    ->setContent('Hello from Laravel!')
    ->send();
```

### Custom Webhook URL

[](#custom-webhook-url)

Specify a different webhook URL for a specific message:

```
DiscordWebhook::make('https://discord.com/api/webhooks/your-custom-webhook-url')
    ->setContent('Custom webhook message')
    ->send();
```

### Customize Username and Avatar

[](#customize-username-and-avatar)

Set a custom username and avatar for the webhook:

```
DiscordWebhook::make()
    ->setUsername('My Custom Bot')
    ->setAvatarUrl('https://example.com/avatar.png')
    ->setContent('Hello with custom identity!')
    ->send();
```

### Rich Embeds

[](#rich-embeds)

Create beautiful embed messages:

```
DiscordWebhook::make()
    ->setContent('Check out this embed!')
    ->addEmbed(function ($embed) {
        $embed->setTitle('Embed Title', 'https://example.com')
              ->setDescription('This is a detailed description of the embed content.')
              ->setColor(0x3498db) // Blue color
              ->addField('Field 1', 'Value 1', true)
              ->addField('Field 2', 'Value 2', true)
              ->addField('Field 3', 'This is a longer value that spans multiple lines', false)
              ->setFooter('Footer text', 'https://example.com/footer-icon.png')
              ->setTimestamp();
    })
    ->send();
```

### Embed Only (No Text)

[](#embed-only-no-text)

Send an embed without text content:

```
DiscordWebhook::make()
    ->addEmbed(function ($embed) {
        $embed->setTitle('Notification')
              ->setDescription('This is an embed-only message')
              ->setColor(0x00ff00) // Green
              ->setTimestamp();
    })
    ->send();
```

### Multiple Embeds

[](#multiple-embeds)

Add multiple embeds to a single message:

```
DiscordWebhook::make()
    ->setContent('Multiple embeds example')
    ->addEmbed(function ($embed) {
        $embed->setTitle('First Embed')
              ->setDescription('This is the first embed')
              ->setColor(0xff0000); // Red
    })
    ->addEmbed(function ($embed) {
        $embed->setTitle('Second Embed')
              ->setDescription('This is the second embed')
              ->setColor(0x0000ff); // Blue
    })
    ->send();
```

### Using Embed Instance Directly

[](#using-embed-instance-directly)

You can also create and pass an embed instance directly:

```
use LarafyStudios\DiscordWebhooks\DiscordEmbed;

$embed = new DiscordEmbed();
$embed->setTitle('Direct Embed')
      ->setDescription('Created directly')
      ->setColor(0xffff00);

DiscordWebhook::make()
    ->setContent('Using direct embed instance')
    ->addEmbed($embed)
    ->send();
```

### Method Chaining

[](#method-chaining)

All methods support fluent chaining:

```
DiscordWebhook::make()
    ->setUsername('My Bot')
    ->setAvatarUrl('https://example.com/avatar.png')
    ->setContent('Chained methods example')
    ->addEmbed(function ($embed) {
        $embed->setTitle('Title')
              ->setDescription('Description')
              ->setColor(0x3498db)
              ->setAuthor('Author Name', 'https://example.com', 'https://example.com/author.png')
              ->setThumbnail('https://example.com/thumbnail.png')
              ->setImage('https://example.com/image.png')
              ->addField('Inline Field 1', 'Value', true)
              ->addField('Inline Field 2', 'Value', true)
              ->addField('Full Width Field', 'Value', false)
              ->setFooter('Footer', 'https://example.com/footer.png')
              ->setTimestamp();
    })
    ->send();
```

API Reference
-------------

[](#api-reference)

### DiscordWebhook Methods

[](#discordwebhook-methods)

MethodDescriptionParameters`make(?string $url = null)`Create a new webhook instance`$url` - Optional webhook URL`setContent(string $content)`Set the message text content`$content` - The message text`setUsername(string $username)`Set the webhook username`$username` - The username`setAvatarUrl(string $avatarUrl)`Set the webhook avatar URL`$avatarUrl` - The avatar URL`addEmbed(callable|DiscordEmbed $embed)`Add an embed to the message`$embed` - Callback or embed instance`send()`Send the webhook messageReturns `bool`### DiscordEmbed Methods

[](#discordembed-methods)

MethodDescriptionParameters`setTitle(string $title, ?string $url = null)`Set the embed title`$title` - Title text, `$url` - Optional title URL`setDescription(string $description)`Set the embed description`$description` - Description text`setColor(int $color)`Set the embed color`$color` - Hex color as integer (e.g., `0x3498db`)`setTimestamp(?\DateTimeInterface $timestamp = null)`Set the embed timestamp`$timestamp` - Optional timestamp (defaults to now)`setFooter(string $text, ?string $iconUrl = null)`Set the embed footer`$text` - Footer text, `$iconUrl` - Optional icon URL`setImage(string $url)`Set the embed image`$url` - Image URL`setThumbnail(string $url)`Set the embed thumbnail`$url` - Thumbnail URL`setAuthor(string $name, ?string $url = null, ?string $iconUrl = null)`Set the embed author`$name` - Author name, `$url` - Optional author URL, `$iconUrl` - Optional icon URL`addField(string $name, string $value, bool $inline = false)`Add a field to the embed`$name` - Field name, `$value` - Field value, `$inline` - Whether field is inlineError Handling
--------------

[](#error-handling)

The `send()` method returns `boolean`:

- `true` if the webhook was sent successfully
- `false` if the webhook failed to send

Errors are automatically logged to Laravel's log system. If the webhook URL is not set, an `InvalidArgumentException` will be thrown during instantiation.

Examples
--------

[](#examples)

### Notification System

[](#notification-system)

```
// In your User model or event listener
use LarafyStudios\DiscordWebhooks\DiscordWebhook;

public function notifyNewUser($user)
{
    DiscordWebhook::make()
        ->setContent("New user registered: {$user->name}")
        ->addEmbed(function ($embed) use ($user) {
            $embed->setTitle('New User Registration')
                  ->setDescription("User {$user->name} ({$user->email}) has registered.")
                  ->setColor(0x00ff00)
                  ->addField('User ID', (string) $user->id, true)
                  ->addField('Email', $user->email, true)
                  ->setTimestamp();
        })
        ->send();
}
```

### Error Reporting

[](#error-reporting)

```
try {
    // Your code here
} catch (\Exception $e) {
    DiscordWebhook::make()
        ->setContent('⚠️ An error occurred in the application')
        ->addEmbed(function ($embed) use ($e) {
            $embed->setTitle('Error Report')
                  ->setDescription($e->getMessage())
                  ->setColor(0xff0000)
                  ->addField('File', $e->getFile(), false)
                  ->addField('Line', (string) $e->getLine(), true)
                  ->setTimestamp();
        })
        ->send();
}
```

Testing
-------

[](#testing)

When testing your application, you may want to prevent actual webhook calls. You can mock the `Http` facade or use a test webhook URL.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

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

Support
-------

[](#support)

For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/LarafyStudios/discord-webhooks).

---

Made with ❤️ by [LarafyStudios](https://github.com/LarafyStudios)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance56

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/108267e29cdc0502d450a94ad1fc5c11df596a53117c632470d84f38c2d64c70?d=identicon)[JavaHampus](/maintainers/JavaHampus)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/larafystudios-discord-webhooks/health.svg)

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

###  Alternatives

[spiral/mcp-server

Spiral bridge for MCP server

541.1k2](/packages/spiral-mcp-server)

PHPackages © 2026

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