- How does this bundle improve performance compared to traditional PHP-FPM + Nginx setups?
- This bundle replaces PHP-FPM with Workerman’s async event loop, preserving the Symfony kernel and DI container between requests. This eliminates the overhead of spinning up new PHP processes for each request, reducing latency and improving throughput—especially for high-traffic APIs or real-time applications like WebSockets. Benchmarks often show 2–10x faster request handling under load.
- Can I use this bundle with Laravel instead of Symfony? Or is it strictly for Symfony?
- This bundle is designed for Symfony, but Laravel developers can explore similar Workerman integrations like `workerman/workerman` directly or check for Laravel-specific forks. The core Workerman library is framework-agnostic, but this bundle’s middleware, console commands, and Symfony-specific optimizations (e.g., kernel persistence) won’t work out-of-the-box in Laravel without significant refactoring.
- What Laravel versions does this bundle support, and are there any breaking changes?
- This bundle explicitly targets Symfony 6.4+, 7.0, and 8.0, not Laravel. However, if you’re using Laravel and need Workerman’s async capabilities, you’d need to integrate the raw `workerman/workerman` library manually. There are no Laravel-specific breaking changes here, but Symfony’s DI system and kernel lifecycle differ from Laravel’s, so direct porting isn’t straightforward.
- How do I configure the bundle to handle WebSocket connections in Laravel?
- Since this bundle is Symfony-focused, Laravel users would need to integrate Workerman directly. Start by installing `workerman/workerman` via Composer, then create a custom event handler for WebSocket connections using Workerman’s `Connection` class. Example: `Worker::onWorkerStart = function() { Worker::listen(8080); $worker->onMessage = function($connection, $data) { /* handle WebSocket */ }; };` Laravel’s event system can then bridge to Workerman via custom logic.
- What are the risks of using Workerman’s process forking model in production?
- Workerman forks processes for workers, which can complicate state management. Shared memory (e.g., Redis) is required for cross-process data like sessions or caches. gRPC users must enable `GRPC_ENABLE_FORK_SUPPORT=1` to avoid deadlocks. Debugging async stack traces is harder than in traditional PHP, and misconfigured `trusted_hosts` can expose HTTP host header attacks. Always test rollback strategies (e.g., fallback to FPM) before full deployment.
- How do I deploy this bundle in a Docker container without root privileges?
- Bind to ports ≥1024 in your `Dockerfile` or `docker-compose.yml` to avoid root requirements. Use the bundle’s PHAR packaging feature to create a self-contained deployment: `php bin/console workerman:phar`. Configure your reverse proxy (e.g., Nginx) to forward traffic to the Workerman-managed port. Ensure `trusted_hosts` in Symfony’s config matches your proxy’s forwarded host headers.
- Can I use this bundle alongside Laravel’s built-in scheduler (e.g., `schedule:run`)?
- No, this bundle replaces Laravel’s scheduler with Workerman’s in-process task scheduler. Migrate cron jobs to the bundle’s `workerman:task` commands or configure Symfony’s `cron` bundle as a fallback. Workerman’s scheduler runs in the same event loop as HTTP requests, offering lower latency than external cron jobs, but requires reworking job definitions to use Workerman’s syntax (e.g., `@hourly`, `@every 5m`).
- What alternatives exist for async HTTP servers in Laravel if this bundle isn’t compatible?
- For Laravel, consider `reactphp/react` for async I/O, `swoole/swoole` for coroutine-based servers, or `spatie/laravel-horizon` for queue workers. If you need WebSockets, `beyondcode/laravel-websockets` (Pusher-compatible) or `ratchetphp/Ratchet` are popular. For pure PHP async, `workerman/workerman` can be integrated manually, but lacks Symfony/Laravel-specific optimizations like this bundle provides.
- How do I monitor memory leaks or process health in a Workerman-powered Symfony app?
- Use Workerman’s built-in metrics via `workerman:server` connections or integrate with tools like Blackfire or XHProf for profiling. Monitor `reload_strategy.memory` in your config to detect leaks, and enable `php-inotify` for efficient file monitoring (polling mode is CPU-intensive). Log async stack traces with `Worker::$logFile` and set up alerts for worker crashes via Symfony’s `monolog` or a dedicated process supervisor like `systemd`.
- Does this bundle support HTTP/2 or HTTPS out of the box?
- This bundle supports HTTPS via standard PHP stream contexts (e.g., `ssl://` in `Worker::listen`). HTTP/2 requires additional configuration, such as enabling it in your reverse proxy (e.g., Nginx) and ensuring your PHP environment supports ALPN. Workerman itself doesn’t natively handle HTTP/2; traffic must be terminated at the proxy level. For self-signed certs, configure `Worker::listen` with custom CA paths or use Let’s Encrypt with your proxy.