- How do I install and configure the RoadRunner bundle in a Laravel application?
- First, require the package via Composer: `composer require baldinof/roadrunner-bundle`. If not using Symfony Flex, manually register the bundle in `config/app.php` under `providers`. Copy default RoadRunner configs (`cp vendor/baldinof/roadrunner-bundle/.rr.* .`), then install the RoadRunner CLI tool (`composer require --dev spiral/roadrunner-cli`) and fetch the binary (`vendor/bin/rr get --location bin/`). Start RoadRunner with `bin/rr serve`.
- Does this bundle work with Laravel 9/10, or is it Symfony-only?
- This bundle is designed for Symfony, but Laravel developers can use it indirectly by leveraging Symfony’s HTTP kernel (e.g., via `symfony/http-kernel`). For native Laravel integration, consider alternatives like `spiral/roadrunner` or `spiral/laravel-roadrunner`. The bundle explicitly supports Symfony 5.4+, 6.x, and 7.x, so Laravel compatibility depends on your setup.
- What are the performance benefits of RoadRunner over PHP-FPM in Laravel?
- RoadRunner uses process-based concurrency with lower overhead than PHP-FPM, reducing latency for high-traffic APIs. It supports kernel reboots to mitigate memory leaks and offers gRPC/KV caching for faster data access. Benchmark your app’s RPS (Requests Per Second) against PHP-FPM to quantify gains, especially for stateless workloads like APIs.
- How do I handle stateful services (e.g., Doctrine connections) in RoadRunner?
- Stateful services risk corruption between requests. Configure `kernel_reboot` in `.rr.yaml` (e.g., `kernel_reboot: always` or `max_jobs: 100`) to reset the Symfony container. For Doctrine, the bundle auto-clears stale connections, but ensure services implement `ResetInterface` if they maintain state. Test with memory-heavy operations to validate stability.
- Can I use gRPC or KV caching with this bundle in Laravel?
- Yes, but indirectly. The bundle enables gRPC/KV for Symfony apps. For Laravel, you’d need to wrap the bundle’s HTTP kernel or use RoadRunner’s CLI tools directly. Alternatively, use `spiral/roadrunner` for native Laravel gRPC/KV support. Configure `.rr.yaml` with `grpc:` or `kv:` sections, then integrate via Symfony’s PSR-15 middleware or Laravel’s service container.
- How do I monitor RoadRunner’s performance in production?
- The bundle includes Prometheus metrics out of the box. Configure `.rr.yaml` with `metrics:` and expose the `/metrics` endpoint. Use tools like Grafana to track request latency, error rates, and worker health. For distributed tracing, pair with OpenTelemetry or Sentry. Monitor kernel reboots via logs (`kernel_reboot: log`) to detect memory leaks or misconfigurations.
- What’s the best way to deploy RoadRunner with Laravel in Docker?
- Use a multi-stage Docker build to embed the RoadRunner binary. Add `RUN vendor/bin/rr get-binary --location /usr/bin/rr` in your build stage, then run `rr serve` in production. Ensure your `Dockerfile` matches your PHP version (e.g., `FROM php:8.2-cli`). For CI/CD, cache the binary to avoid repeated downloads. Test with `rr serve -c .rr.prod.yaml` to validate config.
- Are there alternatives to this bundle for Laravel?
- For Laravel, consider `spiral/laravel-roadrunner` (official integration) or `spiral/roadrunner` (standalone). These packages are tailored for Laravel’s ecosystem and offer similar performance benefits. The Symfony bundle is ideal if you’re using Symfony’s HTTP kernel or need multi-framework compatibility. Compare features like Doctrine integration, middleware support, and gRPC/KV capabilities.
- How do I debug issues like Xdebug not working with RoadRunner?
- RoadRunner supports Xdebug in trigger mode only. Configure `.rr.yaml` with `xdebug:` and set `trigger: true`. For full debugging, use `rr serve --debug` and attach manually. VarDumper dumps bypass HTTP responses, so use `rr serve:dump` for console output. Logs are critical; check `rr logs` for worker errors. Avoid heavy middlewares during debugging, as they may delay cold starts.
- What happens if a worker crashes in production? How do I handle failures?
- RoadRunner’s supervisor automatically restarts crashed workers. Configure `supervisor:` in `.rr.yaml` to set max retries or delay. For Symfony, kernel reboots mask some exceptions, so explicitly allow critical errors via `kernel_reboot: allowed_exceptions`. Monitor logs for OOM kills or infinite loops. Test failure scenarios locally with `rr serve --watch` to simulate crashes and validate recovery.