Download the PHP package discord-php/slash without Composer

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

DiscordPHP-Slash

PHP server and client for Discord slash commands. Please read the Discord slash command documentation before using this library.

If you are already using DiscordPHP v7+ you DO NOT need this DiscordPHP-Slash library. Read more here: https://github.com/discord-php/DiscordPHP/wiki/Slash-Command

Warning

Discord slash commands are still in beta. Expect the way these commands work to change at any time without notice. Same goes for this library.

Requirements

Installation

Usage

There are two "clients" in the library:

Discord\Slash\RegisterClient

You should read up on how commands are registered in the Discord Developer Documentation, specifically the options array when creating and updating commands.

Discord\Slash\Client

There are two ways to set up the slash client:

Please read both sections as both have important information and both have advantages/disadvantages.

Webhook method

Now that you have registered commands, you can set up an HTTP server to listen for requests from Discord.

There are a few ways to set up an HTTP server to listen for requests:

Whatever path you choose, the server must be protected with HTTPS - Discord will not accept regular HTTP.

At the moment for testing, I am running the built-in ReactPHP HTTP server on port 8080 with no HTTPS. I then have an Apache2 web server with HTTPS that acts as a reverse proxy to the ReactPHP server. An example of setting this up on Linux is below.

Setting up a basic Client:

Please note that you must always acknowledge the interaction within 3 seconds, otherwise Discord will cancel the interaction. If you are going to do something that takes time, call the acknowledge() function and then add a follow up message using sendFollowUpMessage() when ready.

This library only handles slash commands, and there is no support for any other interactions with Discord such as creating channels, sending other messages etc. You can easily combine the DiscordPHP library with this library to have a much larger collection of tools. All you must do is ensure both clients share the same ReactPHP event loop. Here is an example:

Running behing PHP-CGI/PHP-FPM

To run behind CGI/FPM and a webserver, the kambo/httpmessage package is required:

The syntax is then exactly the same as if you were running with the ReactPHP http server, except for the last line:

Do note that the regular DiscordPHP client will not run on CGI or FPM, so your mileage may vary.

Setting up Apache2 as a reverse proxy

Assuming you already have Apache2 installed and the SSL certificates on your server:

  1. Enable the required Apache mods:

  2. Create a new site or modify the existing default site to listen on port 443:

  3. Restart apache - the code below works on Debian-based systems:

Gateway method (Deprecated)

Starting with DiscordPHP v7.0.0, slash commands are now integrated into the main library. You no longer need this DiscordPHP-Slash library anymore! Read more here: https://github.com/discord-php/DiscordPHP/blob/master/V7_CONVERSION.md#slash-commands

The client can connect with a regular DiscordPHP client to listen for interactions over gateway. To use this method, make sure there is no interactions endpoint set in your Discord developer application.

Make sure you have included DiscordPHP into your project (at the time of writing, only DiscordPHP 6.x is supported):

You can then create both clients and link them:

The gateway method is much easier to set up as you do not have to worry about SSL certificates.

License

This software is licensed under the MIT license which can be viewed in the LICENSE.md file.

Credits


All versions of slash with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3|>=8.0
react/http Version ^1.2
symfony/options-resolver Version ^5.2
monolog/monolog Version ^2.2
guzzlehttp/guzzle Version ^7.2
discord/interactions Version ^1|^2
simplito/elliptic-php Version ^1
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 discord-php/slash contains the following files

Loading the files please wait ....