Skip to content

v0.2.0 — OxPHP\Server\Worker migration

Latest

Choose a tag to compare

@diolektor diolektor released this 26 Jun 20:40
dfe695f

Highlights

Worker-mode entry now prefers the OxPHP\Server\Worker class introduced in the OxPHP extension (v0.9.0), with a transparent fallback to the free oxphp_*() functions on older servers. Runtime behaviour is unchanged.

Legacy Class API
oxphp_is_worker() Worker::isWorkerMode()
oxphp_worker($h) Worker::current()->serve($h)

The other oxphp_* calls have no class analog and are left untouched. Scope is intentionally minimal (YAGNI) — scheduleExit/requestCount/rss/memoryUsage are not adopted.

Changes

  • Worker class migrationInternal\Bridge\OxPHP is now the single point that decides class vs free function: constructor seam ?bool $useWorkerClass (autodetect via class_exists), new serve(callable): void, dual-path isWorker(). The direct oxphp_worker() call is moved out of the runner, restoring the "only the bridge calls oxphp_*" invariant. AbstractHttpRunner drives the loop through $this->bridge->serve(); the "a broken handler must never poison the worker" invariant is preserved.
  • Fix: runner dispatch testable under CLI SAPIRuntime::getRunner() coupled the SAPI gate with the type→runner dispatch table, so the PHP_SAPI === 'cli' gate short-circuited it under PHPUnit. The dispatch is extracted into a private resolveRunner(); getRunner() behaviour and the public Runtime API are unchanged.

Compatibility

No breaking changes. The only public classes (Runtime, ResetterInterface) are unchanged. Works on both new (class-based) and older (function-based) OxPHP servers.

Full Changelog: v0.1.1...v0.2.0