team-reflex/discord-php
DiscordPHP is a PHP wrapper for Discord’s REST, gateway, and voice APIs. Build Discord bots that run in CLI with ReactPHP-style async handling. Includes limited docs/class reference and community integrations like Laracord for Laravel.
Message, User, Guild) are immutable, typed domain objects that mirror Discord’s API. This aligns well with Laravel’s Eloquent-like patterns but requires adaptation for Laravel’s ORM conventions (e.g., active record vs. DTOs).Intents::MESSAGE_CONTENT) is a critical design choice. Laravel’s event system would need to proxy DiscordPHP events to Laravel’s queue/listener ecosystem, adding complexity.then() chains to Laravel’s dispatch().| Risk Area | Mitigation Strategy |
|---|---|
| CLI-HTTP Integration | Isolate DiscordPHP in a separate process (e.g., Docker container, supervisor). |
| Memory Leaks | Use PHP-FPM + supervisor to restart workers; avoid global state in Laravel. |
| Event Duplication | Implement idempotent event handlers in Laravel to avoid race conditions. |
| Intent Mismatches | Validate intents before enabling them in Discord’s developer portal. |
| Rate Limiting | Use Laravel’s rate-limiting middleware to throttle DiscordPHP API calls. |
| Dependency Conflicts | Pin ReactPHP and PHP versions strictly in composer.json. |
| Debugging Complexity | Log DiscordPHP events to Laravel’s log channel for correlation. |
Intents::MESSAGE_CONTENT (privileged intent; needs approval).Discord::shard()).| Laravel Component | DiscordPHP Equivalent | Integration Strategy |
|---|---|---|
| Service Container | N/A (CLI-only) | Use Laracord or manually bind DiscordPHP classes via bind() in AppServiceProvider. |
| Events | Discord::on() |
Proxy DiscordPHP events to Laravel’s Event::dispatch() via a custom listener. |
| Queues | Async Promises | Convert DiscordPHP then() chains to Laravel dispatch() with a Promise adapter. |
| Logging | Discord::logger |
Redirect to Laravel’s Log::channel() via a custom PSR-3 logger. |
| Configuration | CLI args/env vars | Use Laravel’s .env for token, intents, and bind to DiscordPHP via config(). |
| Testing | Manual CLI tests | Use Laravel’s Pest/Tests with Process::run() to simulate CLI execution. |
Phase 1: Proof of Concept (2-4 weeks)
Phase 2: Laravel Integration (3-6 weeks)
php artisan discord:bot) to start DiscordPHP.ReactPHP\EventLoop\Factory::create() in a Laravel command.Event::dispatch().Phase 3: Scaling & Observability (2-4 weeks)
| Concern | Solution |
|---|---|
| PHP Version | Ensure Laravel’s PHP version (≥8.1) matches DiscordPHP’s requirement. |
| ReactPHP Extensions | Install ext-uv, ext-ev, or ext-event for performance. |
| Windows SSL | Download caextract.crt and configure openssl.cafile in php.ini. |
| Laravel Queues | Use sync driver for testing; redis/database for production. |
| Event Duplication | Use Laravel’s shouldQueue() and unique queue jobs to deduplicate. |
ext-uv, ext-json, ext-zlib).team-reflex/discord-php).message_create → DiscordMessageReceived).POST /discord/send-message).| Task | Complexity | Owner
How can I help you explore Laravel packages today?