- How do I replace Laravel’s public/index.php with Symfony Runtime?
- Replace `public/index.php` with a custom bootstrap file (e.g., `bootstrap/runtime.php`) that initializes `SymfonyRuntime` and delegates execution. Use `$runtime->getRunner()->run()` to handle HTTP/CLI contexts. No config is needed for basic use, but you may override `project_dir` or customize the runner for Laravel-specific needs.
- Will Symfony Runtime break Laravel’s Artisan CLI or middleware?
- Artisan CLI works out-of-the-box, but middleware relying on `$_SERVER` or `$_ENV` will need refactoring. Replace global state access with injected dependencies (e.g., `Request`, `Config`). Use static analysis tools like PHPStan to identify affected middleware during migration.
- Does Symfony Runtime support Laravel’s queue workers (e.g., Horizon, RoadRunner)?
- For HTTP/CLI, it works seamlessly. Worker support requires custom runners (e.g., a `RoadRunnerRuntime` adapter). Start with HTTP/CLI, then extend for workers incrementally. The component is designed for runtime diversity, so adapters are feasible but may need community contributions.
- Can I use Symfony Runtime in Laravel 9.x or older versions?
- Symfony Runtime v7.x supports PHP 7.2+, but Laravel 9.x may need polyfills for compatibility. Test thoroughly, as Laravel’s `bootstrap/app.php` (where the Kernel is instantiated) might require adjustments. Prioritize upgrading to Laravel 10+ for full synergy with Symfony components.
- How does Symfony Runtime improve testability in Laravel?
- By eliminating reliance on `$_SERVER`, `$_ENV`, and global state, tests become deterministic and isolated. Legacy tests using global state may fail initially; refactor them to use injected services (e.g., `Config`, `Request`). This reduces flaky tests and speeds up CI/CD pipelines.
- What’s the performance impact of using Symfony Runtime in Laravel?
- Benchmarking shows minimal overhead (<5% latency increase). The component is optimized for low-cost execution. For serverless/Lambda deployments, it avoids PHP-FPM assumptions entirely, making it ideal for portable, high-performance setups.
- How do I handle Laravel’s Service Providers that use `$_ENV` or `$_SERVER`?
- Refactor providers to inject dependencies (e.g., `Config`, `Environment`) instead of accessing globals. Use Symfony’s `ParameterBag` or Laravel’s `Config` service. Tools like PHPStan can flag global state usage during migration, making this process systematic.
- Are there alternatives to Symfony Runtime for Laravel?
- Laravel’s native bootstrap system works but relies on global state. For decoupling, consider `symfony/runtime` or custom solutions like `league/container` with explicit DI. However, Symfony Runtime offers a standardized, ecosystem-backed approach with built-in support for HTTP/CLI/worker contexts.
- How do I customize Symfony Runtime for Laravel’s Kernel initialization?
- Extend `SymfonyRuntime` to bridge Laravel’s DI container. Override methods like `getKernel()` to instantiate Laravel’s `Kernel` with injected dependencies. Example: `return new Kernel($this->getContainer(), $this->getEnvironment());`. Test with `bootstrap/app.php` to ensure compatibility.
- What’s the maintenance effort for adopting Symfony Runtime in a large Laravel app?
- Effort depends on global state usage. Audit middleware, providers, and listeners first. Start with a phased rollout (e.g., staging environment) and monitor for errors. The component is actively maintained by Symfony, reducing long-term risk. Community support is robust for Laravel-Symfony integrations.