Download the PHP package php-channels/discord-webhook without Composer

On this page you can find all versions of the php package php-channels/discord-webhook. 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 discord-webhook

PHP Discord Webhook

php workflow Latest Stable Version Total Downloads License PHP Version Require

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

Composer

Install

Update

QA

Unit Tests

To run unit tests using PHPUnit:

PHP Stan

To run code static analysis using PHP Stan:

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.

Basic Usage

image

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:

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

2. Username

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

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:

4. Content

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

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:

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

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:

2. Title

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

3. URL

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

4. Description

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

5. Color

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

Note: The color value should be a decimal number. We suggest to use this converter to convert hexadecimal values to decimal.

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

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

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:

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

7. Thumbnail

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

8. Image

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

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:

Usage Example

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.


All versions of discord-webhook with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
guzzlehttp/guzzle Version ^6.3 || ^7.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 php-channels/discord-webhook contains the following files

Loading the files please wait ....