メインコンテンツへスキップ

popLoadedRuntime

Callable

  • popLoadedRuntime(id: number, __namedParameters?: { dangerouslyKeepTheRuntimeInTheMap?: boolean }): PHPRuntime

  • Retrieves a PHP runtime by its ID and removes it from the internal registry.

    When you call loadPHPRuntime(), it creates an Emscripten-based PHP instance and stores it in a module-level Map keyed by a numeric ID. This function is the only way to retrieve that runtime object so you can actually use it.

    The "pop" semantic is intentional: retrieving a runtime also removes it from the registry. This prevents memory leaks since the registry would otherwise hold references to every runtime ever created. Once you pop a runtime, you own it and are responsible for its lifecycle.

    Typical usage flow:

    // 1. Load a PHP runtime (returns just the ID)
    const runtimeId = await loadPHPRuntime(phpLoaderModule);

    // 2. Pop the runtime to get the actual Emscripten module
    const phpRuntime = popLoadedRuntime(runtimeId);

    // 3. Now you can use phpRuntime to run PHP code, access the filesystem, etc.
    @throws

    If no runtime exists with the given ID.


    Parameters

    • id: number

      The numeric ID returned by loadPHPRuntime().

    • __namedParameters: { dangerouslyKeepTheRuntimeInTheMap?: boolean } = {}
      • optionaldangerouslyKeepTheRuntimeInTheMap: boolean = false

    Returns PHPRuntime

    The PHP runtime object (an Emscripten module instance).