Octane development

From Inikoo-Ltd/aiku · View interactive version

Octane development is an AI agent skill from the GitHub repository Inikoo-Ltd/aiku. Use this skill when working with Laravel Octane, a long-running PHP worker server (Swoole, FrankenPHP, RoadRunner) where the application boots once and serves many requests instead of rebooting for each request like PHP-FPM. Trigger when installing Octane or starting its server; configuring or detec

How to use this skill

Skill file

Laravel Octane

Octane boots the application container once and reuses it across requests in a long-running worker. Follow these rules to avoid Octane-specific bugs caused by PHP-FPM assumptions.

Always verify against the docs. Octane's APIs, configuration keys, and driver options change between versions. Before giving setup steps, configuration examples, or exact API syntax, call the Laravel Boost search-docs tool scoped to the installed laravel/octane version. Treat the rules below as durable patterns, and treat search-docs as the source of truth for specifics such as installation commands, Caddyfile and .rr.yaml configuration, server flags, and method signatures.

Detect the Driver First

Read config('octane.server') to determine the driver: swoole, roadrunner, or frankenphp. Guard Octane::concurrently(), Octane::table(), the octane cache store, and ticks or intervals behind this check, because they run on Swoole only.

State Isolation (all drivers)

Avoid storing request-specific state in singletons or static properties. State set during one request can survive into the next, which is the most common source of Octane bugs.

// Avoid: holds request 1's user for every later request
$this->app->singleton(UserContext::class);

// Prefer: flushed and re-resolved per request
$this->app->scoped(UserContext::class);

Memory (all drivers)

Free what you allocate. Workers are long-lived, so anything left referenced can accumulate until the worker crashes.

Concurrency (Swoole only)

Guard the driver, then run closures in parallel:

[$users, $orders] = Octane::concurrently([
    fn () => User::all(),
    fn () => Order::pending()->get(),
]);

Swoole Tables and `octane` Cache (Swoole only)

Testing (all drivers)

Common Pitfalls

These issues recur when developing applications on Octane. Guard against each one as you write code.

References

Verify driver-specific details against the official docs, because versions and configuration keys change:

Verification

  1. Confirm config('octane.server') matches the driver assumed by any Swoole-only code.
  2. Confirm no request-derived state lives in a singleton or static without scoped, flush, or a reset.
  3. Confirm a worker recycle limit (max_requests or max_jobs) is configured.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.