cyberwolf-studio/discord-php

Discord API & Gateway wrapper for PHP. A rebranded, maintained fork of Ragnarok/Fenrir.

Maintainers

Package info

github.com/cyberwolf-studio/discord-php

Homepage

Issues

pkg:composer/cyberwolf-studio/discord-php

Transparency log

Statistics

Installs: 8

Dependents: 1

Suggesters: 0

Stars: 0

v1.0.1 2026-08-26 13:22 UTC

This package is auto-updated.

Last update: 2026-08-26 13:22:51 UTC


README

Discord PHP

PHP Discord Interface — API & Gateway wrapper.

Code Quality Unit Tests

About

Discord PHP is a mostly plain wrapper over Discord's APIs/gateway. There is no caching built in; this is for the user to implement themselves.

It heavily relies on ReactPHP for async operations. Knowing the basics of async PHP is recommended before diving in.

Discord PHP is a rebranded, maintained fork of Fenrir by Ragnarök. See Credits below.

Install

composer require cyberwolf-studio/discord-php

Example bot

use CyberWolf\Discord\Bitwise\Bitwise;
use CyberWolf\Discord\Constants\Events;
use CyberWolf\Discord\Discord;
use CyberWolf\Discord\Enums\Intent;
use CyberWolf\Discord\Gateway\Events\MessageCreate;
use CyberWolf\Discord\Rest\Helpers\Channel\MessageBuilder;

require './vendor/autoload.php';

$discord = new Discord('TOKEN');

$discord
    ->withGateway(Bitwise::from(
        Intent::GUILD_MESSAGES,
        Intent::DIRECT_MESSAGES,
        Intent::MESSAGE_CONTENT,
    ))
    ->withRest();

$discord->gateway->events->on(Events::MESSAGE_CREATE, function (MessageCreate $message) use ($discord) {
    if ($message->content === '!ping') {
        $discord->rest->channel->createMessage(
            $message->channel_id,
            (new MessageBuilder())
                ->setContent('pong!')
        );
    }
});

$discord->gateway->open(); // Nothing after this line is executed

REST-only example

use CyberWolf\Discord\Discord;
use CyberWolf\Discord\Rest\Helpers\Channel\MessageBuilder;

require './vendor/autoload.php';

$discord = new Discord('TOKEN');
$discord->withRest();

$discord->rest->channel->createMessage(
    'channel-id',
    (new MessageBuilder())
        ->setContent('Hi there!')
);

(Note: going with REST-only means you do NOT receive any events and your bot will appear offline)

For more examples, check out the examples directory.

Support

Discord PHP currently supports PHP 8.5+. Tests should pass on nightly builds of newer versions, but this is not a supported usecase.

Note: Bugfixes/features will not be backported to older versions. Older versions are as-is.

If you're using this in an Apache2/Nginx/etc webserver environment, you should probably limit yourself to only using the REST capabilities. These environments typically don't allow long-running processes.

32-bit is not supported, though no hard limit is in place.

Contributing

Contributions are welcome. You can look for @todo to find something that requires attention. Please make sure to write tests where possible & make sure your code matches the phpcs configuration. Thanks!

Credits

Discord PHP is a fork of Fenrir, originally created by Ragnarök and released under the MIT License. All original copyright is retained in LICENSE. Huge thanks to the original authors and contributors for the foundation this project is built on.

Notice

The current underlying HTTP component is subject to change in the future. While the accessible API for it will remain similar, you should try to refrain from using it manually in your application.

License

Released under the MIT License. See LICENSE for the full text, including the original Fenrir copyright.