Weave Code
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. Build Discord bots and integrations in CLI using an event-driven approach (ReactPHP). Includes guides and class reference; community Laravel integration available via Laracord.

View on GitHub
Deep Wiki
Context7

DiscordPHP is a PHP wrapper for Discord’s official REST, Gateway, and Voice APIs, built to run in CLI environments (not traditional web servers like Apache/nginx). It’s framework-agnostic and suited for long-running bot processes, with community integrations available (e.g. Laracord for Laravel).

Key features:

  • Unified access to Discord REST, realtime Gateway, and Voice
  • Designed for stable, long-lived CLI bot runtimes
  • Helpful docs and class reference (with an active support Discord)
  • Optional ReactPHP compatibility for building HTTP interfaces
  • Experimental cache interface available (not production-ready)
Frequently asked questions about Discord Php
Can I use DiscordPHP directly in a Laravel web app (e.g., for slash commands or API routes)?
No, DiscordPHP is CLI-only and requires a non-blocking event loop (like ReactPHP). For Laravel, run it as a separate CLI process (e.g., via Artisan or a supervisor) and communicate via queues or HTTP endpoints. Laracord provides partial integration but isn’t a full solution.
How do I install DiscordPHP in Laravel? Should I use Composer or Laracord?
Install via Composer with `composer require team-reflex/discord-php`. For Laravel-specific bindings, add `laracord/laracord` (`composer require laracord/laracord`), but note it’s community-maintained. Run the bot via CLI (e.g., `php artisan discord:bot`) or as a background service.
What Laravel versions does DiscordPHP support? Will it work with Laravel 10+?
DiscordPHP itself is framework-agnostic and doesn’t enforce Laravel version constraints. However, Laracord (the Laravel integration) may lag behind updates. Test thoroughly with your Laravel version, as async CLI processes (ReactPHP) can conflict with Laravel’s HTTP lifecycle.
How do I handle Discord’s rate limits in Laravel? Can I use Laravel’s cache?
Laravel’s `cache()` or `remember()` methods can help cache API responses, but DiscordPHP’s async nature complicates this. For rate-limited endpoints (e.g., bulk deletes), use DiscordPHP’s built-in rate-limit handlers or queue delayed requests via Laravel’s queues.
Is DiscordPHP-Voice compatible with Laravel? How do I manage audio streams?
DiscordPHP-Voice requires a separate CLI process for audio handling. Avoid embedding it in Laravel’s HTTP server (risk of crashes). Use Docker containers or a dedicated server for voice operations, communicating with Laravel via queues or WebSocket proxies.
What’s the best way to persist bot state (e.g., cooldowns, user data) in Laravel?
Laravel’s database/Redis is ideal, but DiscordPHP’s async model means you’ll need to sync state manually. Use Laravel’s queues to defer state updates or implement a shared cache (e.g., Redis) with atomic operations. Avoid Laravel’s session storage—it’s HTTP-bound.
Can I use DiscordPHP with Laravel’s queues (e.g., for async message processing)?
Yes, but with caveats. Queue jobs for non-critical tasks (e.g., sending follow-up messages) to avoid blocking the event loop. For time-sensitive operations (e.g., interactions), use DiscordPHP’s native async callbacks. Test thoroughly—queues add latency.
Are there alternatives to DiscordPHP for Laravel Discord bots?
Yes: **JDA (Java)**, **discord.js (Node.js)**, or **Pycord (Python)** are mature. For PHP, **Laravel Discord** (community packages like `spatie/laravel-discord`) offers HTTP-based alternatives, but lack Gateway/Voice support. DiscordPHP is the only full-featured PHP option.
How do I debug DiscordPHP in Laravel? Can I use Laravel’s logging?
Use Laravel’s `Log` facade for bot logs, but DiscordPHP’s async errors may bypass Laravel’s exception handler. Wrap DiscordPHP code in try-catch blocks and log raw exceptions. For CLI debugging, run the bot standalone (`php vendor/bin/discord-php`) with `error_reporting(E_ALL)`.
What PHP extensions are required for DiscordPHP, and how do I configure them in Laravel?
DiscordPHP needs PHP 8.1.2+, `ext-uv` (for async), and `ext-gmp`. In Laravel, add these to your `php.ini` or use a `.user.ini` file in your project root. For shared hosting, ensure your server supports these extensions—DiscordPHP won’t work on default Laravel Forge/Forge stacks.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport