- How do I install and set up Roadrunner in a Laravel application?
- First, install the bundle via Composer: `composer require andrey_mireichyk/roadrunner-bundle`. Register the bundle in `config/app.php` under the `providers` array. Copy the default Roadrunner config files (`cp vendor/andrey_mireichyk/roadrunner-bundle/.rr.* .`) to your project root. Run `vendor/bin/rr get --location bin/` to fetch the Roadrunner binary, then start it with `bin/rr serve`.
- Does this bundle support Laravel’s Eloquent ORM for database connections?
- The bundle primarily handles Doctrine connections via `symfony/proxy-manager-bridge`. For Eloquent, you’ll need to implement a custom connection handler or use a workaround like re-establishing connections per request, as Roadrunner’s stateless model conflicts with persistent connections. Test thoroughly in staging before production.
- Can I use this bundle with Laravel’s built-in middleware (e.g., CORS, auth)?
- Yes, but with caveats. Middleware relying on Symfony’s `Kernel::handle()` or stateful services (e.g., `RequestStack`) may break. The bundle supports PSR-15 middleware, so refactor middleware to avoid kernel dependencies. Test all middleware in a Roadrunner environment before deployment.
- What Laravel versions does this bundle support, and how do I check compatibility?
- The bundle targets Symfony 5.4+ (Laravel 8+). Check the package’s `composer.json` for exact version constraints. For Laravel 9/10, ensure your Symfony components (e.g., `symfony/psr-http-message-bridge`) are up-to-date. The README or GitHub issues will list tested versions.
- How do I configure Roadrunner to work with Laravel’s queue system (e.g., Redis)?
- This bundle focuses on HTTP workloads, but you can use Roadrunner’s RPC capabilities for async tasks. Configure a separate `rr.yaml` for workers with a relay (e.g., `tcp://localhost:6001`) and use `vendor/bin/rr worker` to process queues. Laravel’s queue workers will need to connect to the same relay.
- Will Roadrunner replace PHP-FPM in my Laravel deployment, or should I run both?
- Roadrunner can replace PHP-FPM for HTTP routes, but running both is possible for gradual adoption. Use middleware to route specific paths to Roadrunner (e.g., `/api/*`) while keeping legacy routes in PHP-FPM. Monitor performance and stability during the transition.
- How do I handle database connection failures in Roadrunner without crashing the worker?
- By default, connection failures terminate the worker. To mitigate this, install `symfony/proxy-manager-bridge` and configure the bundle to retry or log failures instead of crashing. For Eloquent, implement a connection retry logic in your service container or middleware.
- Are there performance tradeoffs when using Roadrunner with Laravel’s session handling?
- Yes, Roadrunner’s stateless model can disrupt session persistence. If using database-backed sessions (e.g., Doctrine), ensure the connection handler is configured to clear sessions post-request. For file-based sessions, consider switching to Redis or Memcached for better concurrency.
- Can I monitor Roadrunner’s metrics (e.g., request latency, errors) in Laravel?
- The bundle integrates with Prometheus via Go-side configuration. Enable metrics in `.rr.yaml` (e.g., `metrics: true`) and expose the `/metrics` endpoint. Use tools like Grafana to visualize data. For Sentry, ensure the `SentryBundle` is installed and configured to clear scopes post-request.
- What’s the rollout strategy for Roadrunner in production? How do I update the Go binary?
- Start with a canary deployment (e.g., 10% of traffic) to monitor stability. Update the Go binary by running `vendor/bin/rr get --location bin/` and restarting Roadrunner. Use a process manager (e.g., systemd) to handle updates gracefully. Test rollbacks by reverting to PHP-FPM if issues arise.