Download the PHP package arthurpar06/laravel-discord-notifier without Composer

On this page you can find all versions of the php package arthurpar06/laravel-discord-notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-discord-notifier

Laravel Discord Notifier

Latest Version on Packagist Total Downloads

A strongly-typed way to send Discord messages through Laravel's notification system — over a webhook or a bot — without ever hand-writing the Discord API payload again.

Your IDE and the type system remember the field names, the enums, and the limits — so you don't have to reopen the Discord docs every time.

Installation

Publish the config file:

To deliver via a bot, set your bot token in .env:

There is no default route — every notification declares where it goes.

Building a message

DiscordMessage models the Create Message body. Everything is fluent and typed:

Only the fields you set are sent. Discord's limits (≤10 embeds, content ≤2000 chars, embed field caps, the IS_COMPONENTS_V2 mutual-exclusivity rule, …) are validated when the message is serialized, with an exception that names the offending field.

Buttons

Attach buttons with ->button() (a single button in its own row) or ->actionRow() (up to five buttons per row, up to five rows per message). Buttons are built through a named constructor per style, so you can't assemble an invalid combination:

Constructor Style Needs
Button::link($url, $label = null) Link a URL
Button::primary/secondary/success/danger($customId, $label) interactive a custom_id
Button::premium($skuId) Premium an SKU id

All non-premium buttons also support ->disabled() and ->emoji('🔥') (or a custom emoji array).

Interactive buttons need your own interaction handling. This package only sends messages. link and premium buttons work with nothing extra, but primary/secondary/success/danger buttons raise a Discord Interaction when clicked — if your application does not answer it (via a gateway or an HTTP interactions endpoint) within three seconds, Discord shows "This interaction failed." Reach for link buttons unless you already run an interaction handler.

Sending notifications

In your notification, list discord in via() and return a DiscordMessage from toDiscord():

Route on demand

Pass a bot channel id (a guild channel or a user's DM channel) or an explicit route:

Route from a model

Give the notifiable a routeNotificationForDiscord() returning its own channel id — e.g. a stored private DM channel:

Returning null is safe: a notifiable with no route is skipped, so discord can sit in a via() list alongside other channels even when only some of your users have linked their account.

How routing is resolved

The route value is resolved to a transport, unambiguously:

Route value Transport
DiscordRoute::webhook($url) / DiscordRoute::channel($id) as declared
a string starting with http webhook
a numeric snowflake string bot channel (POST /channels/{id}/messages)

A DM to a user and a message to a guild channel are the same bot call — store the channel id and send.

When there is no route

Situation Result
a notifiable returns null, '' or [] skipped — no message, no exception
Notification::route('discord', '') throws — you asked for delivery but gave no destination
any route that is neither a URL nor a snowflake (e.g. 'not-a-url') throws — a present-but-invalid route is a misconfiguration

An absent route and a malformed one are different things. A model with nothing stored is ordinary and stays quiet; a value that was meant to be a destination and isn't fails loudly.

Testing

License

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


All versions of laravel-discord-notifier with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package arthurpar06/laravel-discord-notifier contains the following files

Loading the files please wait ...