An implementation of discords gateway API in PHP.

License: MIT

Language: PHP


Build Status Discord Chat PHP Discorders

An unofficial library to interact with the Discord gateway API (continuation of DiscordPHP).


  1. Can I run DiscordPHP on a webserver (e.g. Apache, nginx)?
    • No, DiscordPHP will only run in CLI. If you want to have an interface for your bot you can integrate react/http with your bot and run it through CLI.

Getting Started

Installing DiscordPHP

DiscordPHP is installed using Composer. Make sure you have installed Composer and are used to how it operates. We require a minimum PHP version of PHP 5.5.9, however it is reccomended that you use PHP 7. PHP 5.x support will be removed in the future.

This library has not been tested with HHVM.

  1. Run composer require team-reflex/discord-php. This will install the lastest release.
    • If you would like, you can also install the development branch by running composer require team-reflex/discord-php dev-develop.
  2. Include the Composer autoload file at the top of your main file:
    • include __DIR__.'/vendor/autoload.php';
  3. Make a bot!

Basic Example


include __DIR__.'/vendor/autoload.php';

use Discord\Discord;

$discord = new Discord([
	'token' => 'bot-token',

$discord->on('ready', function ($discord) {
	echo "Bot is ready!", PHP_EOL;

	// Listen for messages.
	$discord->on('message', function ($message, $discord) {
		echo "{$message->author->username}: {$message->content}",PHP_EOL;



  • This library can use a lot of RAM and PHP may hit the memory limit. To increase the memory limit, use ini_set('memory_limit', '200M') to increase it to 200 mb. If you would like it to be unlimited, use ini_set('memory_limit', '-1').


Raw documentation can be found in-line in the code and on the DiscordPHP Class Reference. More user friendly and examples will soon be coming on the DiscordPHP Wiki.


We are open to contributions. However, please make sure you follow our coding standards (PSR-4 autoloading and custom styling). We use StyleCI to format our code. Our StyleCI settings can be found here.

Library Comparison

See this chart for a feature comparison and list of other Discord API libraries.

Project Statistics

Sourcerank 2
Repository Size 11.2 MB
Stars 2
Forks 0
Watchers 1
Open issues 0
Dependencies 14
Contributors 6
Tags 23
Last updated
Last pushed

Top Contributors See all

David Aaron Scherer Jack Noordhuis Daniel Holmes Emeric Michele Della Neve

Packages Referencing this Repo

An unofficial API to interact with the voice and text service Discord.
Latest release v4.0.3 - Updated - 2 stars

Recent Tags See all

v4.0.3 December 28, 2016
v4.0.2 October 11, 2016
v4.0.1 August 19, 2016
v4.0.0 July 28, 2016
v3.2.4 June 18, 2016
v3.2.3 May 27, 2016
v3.2.2 May 26, 2016
3.2.1 April 15, 2016
v3.2.0 April 09, 2016
v3.1.2 February 20, 2016
v3.1.1 February 15, 2016
v3.1.0 February 12, 2016
v3.0.3 January 16, 2016
v3.0.2 January 13, 2016
v2.1.3 January 13, 2016

Something wrong with this page? Make a suggestion

Last synced: 2017-10-10 08:16:48 UTC

Login to resync this repository