Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Discord Php

Discord Php Laravel Package

team-reflex/discord-php

DiscordPHP is a PHP wrapper for Discord's REST, gateway, and voice APIs, letting you build feature-rich Discord bots that run in CLI environments. It's framework-agnostic, with community integrations like Laracord for Laravel.

View on GitHub
Deep Wiki
Context7

DiscordPHP is a PHP wrapper for the official Discord REST, gateway and voice APIs, letting you build feature-rich Discord bots entirely in PHP. Designed for CLI environments, it handles connections, events and rate limits so you can focus on your bot's logic.

  • Full support for REST, gateway (WebSocket) and voice APIs
  • Event-driven architecture for handling messages, guilds and members
  • Seamless ReactPHP integration for asynchronous operation
  • Laravel support via the community laracord/laracord integration
Frequently asked questions about Discord Php
How do I install DiscordPHP with Composer?
Install it with composer require team-reflex/discord-php and run your bot from the command line, for example php bot.php. DiscordPHP requires a CLI SAPI, so it will not run under Apache, nginx or php-fpm. Voice support additionally needs the ext-uv or ext-sockets extension, and long-running bots often raise memory_limit. Pin the version in composer.json and test upgrades in staging before deploying.
Can DiscordPHP run inside a Laravel HTTP request or a queue worker?
No. DiscordPHP is built around a ReactPHP event loop and a long-lived gateway WebSocket connection, which does not fit Laravel's request/response lifecycle or a blocking queue worker. Run the bot as a separate CLI process managed by Supervisor or a container orchestrator. Laravel should communicate with it over Redis, queues or an HTTP surface instead of invoking it inline.
Does DiscordPHP work with Laravel?
DiscordPHP itself is framework-agnostic, but the community-maintained laracord/laracord package provides service container bindings, configuration publishing and an event bridge for Laravel. Laracord is maintained independently of the core project and can lag the latest Laravel LTS, so pin it to a branch you have tested. It is the recommended integration path; nothing Laravel-specific ships in team-reflex/discord-php itself.
Can Laravel and a DiscordPHP bot share state or memory?
No. The bot process keeps its state in memory and Laravel cannot read or write that memory directly. Any data both sides need, such as guild rosters, member records or session state, must go through Redis, a database or a message queue. Keep one side authoritative for writes to avoid stale caches; the roster cache fix for REST member mutations helps but does not replace a clear ownership model.
How do I send a command from Laravel to a running DiscordPHP bot?
There is no native HTTP-to-CLI bridge, so the common pattern is Redis Pub/Sub or a queue: Laravel publishes a job and the bot subscribes and dispatches it into its event loop. Alternatively, expose a react/http server inside the bot process and call it from Laravel. Treat the call as asynchronous and return results through a queue or callback.
How do I gracefully restart a DiscordPHP bot during deployments?
Run the bot under Supervisor or a container orchestrator so restarts are supervised. Version 10.67.0 fixed a WebSocket connection race during shutdown (PR #1516), which materially improves graceful restarts and zero-downtime deploys for a stateful bot process. Still validate shutdown and reconnect behaviour in staging, and drain in-flight work before terminating.
What are OpenAPI preview fields in DiscordPHP and are they safe to use?
Recent releases align DiscordPHP with Discord's OpenAPI description and explicitly flag preview-only fields, so payload shapes are more predictable than in older versions. Preview fields are not covered by semantic versioning and can change or disappear without notice. Feature-flag any command that depends on them in your Discord config and audit on each upgrade. Treat them as non-contractual and keep stable-field fallbacks where possible.
How does DiscordPHP handle OAuth2 account linking for Laravel users?
Version 10.67.0 adds backend OAuth2 account linking and revocation (PRs #1522 and #1527) and preserves token issuance origin with provisional reacquisition. That gives you a first-class way to map Discord identities to Laravel users without bespoke OAuth glue. You still need to design a re-acquisition flow in your auth and session layer, configure redirect and issuer allowlists explicitly, and test revocation and re-link paths. Log token origin for audit trails.
How do I avoid Discord API rate limits and 429 errors with DiscordPHP?
Discord enforces per-route rate limits, and bulk guild or member fetches are the usual source of 429s. Add exponential backoff and rate-limit tracking, and offload bulk work to Laravel queues rather than running it inside the gateway loop. Only request the intents and cache sizes you actually need. Isolate heavy tasks in separate workers so the bot stays responsive.
What are the alternatives to DiscordPHP for a Discord bot in Laravel?
If you only need to post messages or manage resources, you can skip the gateway entirely and call Discord's REST API from Laravel with the HTTP client. For full gateway bots, laracord/laracord is a Laravel-friendly layer built on DiscordPHP rather than a replacement. Other PHP Discord libraries exist but are generally less actively maintained, so check release cadence and PHP version support before choosing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin