DiscordPHP Documentation

Guide

DiscordPHP is a wrapper for the Discord REST, WebSocket and Voice APIs. Built on top of ReactPHP components. This documentation is based off the latest release.

Requirements

  • PHP 8.0 or higher

    • Will not run on a webserver (FPM, CGI), you must run through CLI. A bot is a long-running process.
    • x86 (32-bit) PHP requires ext-gmp extension enabled.
  • ext-json for JSON parsing.
  • ext-zlib for gateway packet compression.

Voice Requirements

  • 64-bit PHP
  • ext-sodium for voice encryption.
  • FFmpeg

Development Environment Recommendations

We recommend using an editor with support for the Language Server Protocol. A list of supported editors can be found here. Here are some commonly used editors:

  • Visual Studio Code (built-in LSP support)
  • Vim/Neovim (with the coc.nvim plugin for LSP support)
  • PHPStorm (built-in PHP support)

We recommend installing PHP Intelephense alongside your LSP-equipped editor for code completion alongside other helpful features. There is no need to pay for the premium features, the free version will suffice.

Installation

Installation requires Composer.

To install the latest release:

$ composer require team-reflex/discord-php

If you would like to run on the latest master branch:

$ composer require team-reflex/discord-php dev-master

master can be substituted for any other branch name to install that branch.

Key Tips

As Discord is a real-time application, events come frequently and it is vital that your code does not block the ReactPHP event loop. Most, if not all, functions return promises, therefore it is vital that you understand the concept of asynchronous programming with promises. You can learn more about ReactPHP promises here.

Help

If you need any help, feel free to join the PHP Discorders Discord and someone should be able to give you a hand. We are a small community so please be patient if someone can't help you straight away.

Contributing

All contributions are welcome through pull requests in our GitHub repository. At the moment we would love contributions towards:

  • Unit testing
  • Documentation

Search results