- Can I use DiscordPHP-Voice in a Laravel application without DiscordPHP?
- No, this package is a specialized extension for DiscordPHP and requires it as a dependency. If your Laravel app doesn’t already use DiscordPHP, you’ll need to integrate it first, which includes setting up ReactPHP’s event loop. This may require additional configuration like bridging ReactPHP with Laravel’s async handling (e.g., using spatie/async).
- What PHP versions and Laravel versions are supported?
- This package requires PHP 8.3 or higher due to its reliance on modern features like Promises and FFI. For Laravel, it’s best suited for versions 9+ where async support (e.g., ReactPHP) is more straightforward. Older Laravel versions may lack compatibility with the event loop requirements.
- How do I handle the libdave and ext-ffi dependencies in production?
- Libdave and ext-ffi are mandatory for DAVE protocol compliance. Use the provided `setup-libdave.sh` script to install libdave, and ensure ext-ffi is enabled in your PHP configuration. Shared hosting may not support these dependencies, so consider using a custom VPS or Docker setup for production environments.
- What are the system requirements beyond PHP extensions?
- You’ll need FFmpeg and libsodium for audio processing (e.g., Opus codec). These are typically installed via package managers like `apt` (Linux) or `brew` (macOS). Ensure your server has these tools available, especially if you plan to record or stream audio, as they’re required for encoding/decoding.
- How do I integrate DiscordPHP-Voice with Laravel’s event system?
- Since DiscordPHP-Voice relies on ReactPHP’s event loop, you’ll need to bridge it with Laravel. Use packages like `spatie/async` or create a custom ReactPHP listener to handle async events. Initialize the DiscordPHP client and voice client after the event loop starts, ensuring voice operations don’t block HTTP routes.
- What happens if libdave is missing during runtime?
- The package throws a `LibDaveNotFoundException` if libdave isn’t detected. There’s no fallback, so you must manually install it using the provided script. This is a critical setup step—ensure it’s part of your CI/CD pipeline or deployment process to avoid runtime failures.
- Can I use this package for audio playback only, or do I need recording capabilities?
- You can use it for playback-only scenarios, which simplifies dependencies (no need for FFmpeg/libsodium). However, recording requires additional setup (FFmpeg, libsodium) and may introduce latency or resource constraints. Clarify your use case upfront to avoid unnecessary complexity.
- How do I handle voice connection failures or exceptions in production?
- The package provides granular exceptions (e.g., `EnterChannelDeniedException`). Implement retry logic for transient failures, like reconnecting to voice channels. Use Laravel’s queue system for long-running voice operations to avoid blocking HTTP requests.
- What’s the maximum number of concurrent voice connections supported?
- The package has a hard limit of 25 concurrent decoders. If you expect more users, consider sharding your bot or optimizing audio processing to reduce resource usage. Monitor latency (500ms initial delay + 20ms frames) to ensure a smooth user experience.
- Are there alternatives to DiscordPHP-Voice for Laravel voice support?
- If DiscordPHP isn’t a fit, alternatives like `php-discord/voice` (for Discord.js PHP ports) or custom WebSocket solutions may work, but they lack DAVE encryption compliance. For Laravel-specific needs, evaluate whether voice support is critical—some use cases may suffice with text-based alternatives or third-party APIs.