- How do I install Laravel Octane in an existing Laravel 10+ project?
- Run `composer require laravel/octane` and configure your server (Swoole, RoadRunner, or FrankenPHP) via the `APP_SERVER` environment variable. Octane integrates seamlessly with Laravel’s conventions—no core changes needed. Follow the [official setup guide](https://laravel.com/docs/octane#installation) for server-specific instructions.
- Does Octane work with Laravel Horizon for queue workers?
- Octane doesn’t replace Horizon’s queue workers, but it can significantly speed up queue processing when using async servers like Swoole or RoadRunner. For best results, pair Octane with async database drivers (e.g., `swoole-pdo`) and avoid blocking I/O in queue jobs. Test with `APP_DEBUG=true` to catch async deadlocks.
- What Laravel versions support Octane 2.x, and is downgrading possible?
- Octane 2.x requires **Laravel 10+** and **PHP 8.1+**. Downgrading to Octane 1.x isn’t recommended due to breaking changes in Laravel’s DI container. If you’re on Laravel 9, use Octane 1.x, but note it lacks support for newer Laravel features like async I/O improvements.
- Can I use Octane with Inertia.js or SSR frameworks?
- Octane may break SSR frameworks like Inertia.js if not configured properly, as it maintains a persistent PHP process. Use `APP_DEBUG=true` and ensure per-request state isolation. For Inertia, test with `inertia:middleware` and avoid global state in middleware. FrankenPHP’s PHP-only mode is often the safest choice for SSR.
- How do I handle sessions in Octane? Does it support Redis or database drivers?
- Octane requires **stateless sessions**—avoid the `array` driver. Use `redis` or `database` drivers for session storage to ensure consistency across workers. For Swoole/RoadRunner, enable async session handlers (e.g., `swoole-redis`) to prevent blocking. Test session persistence during worker reloads.
- What’s the difference between Octane’s Boost framework and Laravel’s container?
- Boost is Octane’s **dependency injection layer** optimized for async servers, replacing Laravel’s container in some cases. It avoids circular dependencies but may expose hidden issues in your DI graph. Refactor services to use interfaces and avoid singletons. Boost is transparent for most Laravel apps but requires testing with `php artisan octane:boost --test`.
- How do I deploy Octane in production? Does it support Docker or Kubernetes?
- Octane works in Docker/Kubernetes but requires server-specific configurations. For Swoole/RoadRunner, use multi-worker setups (e.g., `worker_num=4`) for horizontal scaling. FrankenPHP bundles Caddy, so include its `Caddyfile` in your Docker build. Monitor workers with `octane:workers` CLI commands and use external log aggregation (e.g., ELK) for stderr/stdout.
- Will Octane break my existing Laravel packages (e.g., Laravel Passport, Cashier)?
- Most packages work out-of-the-box, but some (like Passport or Horizon) may need async-compatible patches. Test thoroughly with `APP_DEBUG=true`. For Swoole, ensure packages use async drivers (e.g., `swoole-pdo` for databases). Check the [Octane compatibility list](https://laravel.com/docs/octane#package-compatibility) for known issues.
- How do I debug async deadlocks or stack traces in Octane?
- Enable `APP_DEBUG=true` and use server-specific tools: Swoole’s `swoole_trace()` or RoadRunner’s `rr trace`. Avoid blocking calls (e.g., `file_get_contents()`, `sleep()`) in async contexts. For FrankenPHP, check Caddy’s access logs. Octane’s CLI (`octane:workers`) helps inspect worker states during debugging.
- What are the alternatives to Octane for high-performance Laravel apps?
- Alternatives include **RoadRunner** (standalone, supports PHP/Go), **Swoole’s standalone mode**, or **PHP-FPM with OPcache tuning**. For serverless, consider **Bref** or **AWS Lambda**. Octane’s advantage is its **Laravel-first integration**—no need to rewrite core logic. If you’re not using Laravel, RoadRunner or Swoole alone may suffice.