Title: PHP.js JavaScript module
Published: July 15, 2026
Last modified: July 16, 2026

---

# PHP.js JavaScript module

## In this article

 * [PHP.js JavaScript module](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#php-js-javascript-module)
 * [Loading the PHP runtime](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#loading-the-php-runtime)

[ Back to top](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#wp--skip-link--target)

### 󠀁[PHP.js JavaScript module](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#php-js-javascript-module)󠁿

The `php.js` file generated by the [WebAssembly PHP build pipeline](https://developer.wordpress.org/playground/developers/architecture/wasm-php-compiling)
is **not** a vanilla Emscripten module. Instead, it’s an ESM module that wraps the
regular Emscripten output and adds some extra functionality.

Here’s the API it exposes:

    ```javascript
    // php.wasm size in bytes:
    export const dependenciesTotalSize = 5644199;

    // php.wasm filename:
    export const dependencyFilename = 'php.wasm';

    // Run Emscripten's generated module:
    export default function (jsEnv, emscriptenModuleArgs) {}
    ```

The generated JavaScript module is not meant for direct use. Instead, it can be 
consumed through the `PHP` class:

    ```javascript
    // In Node.js:
    const php = new PHP(await loadNodeRuntime('8.0'));

    // On the web:
    const php = new PHP(await loadWebRuntime('8.0'));
    ```

Both of these classes extend the `BasePHP` class exposed by the `@php-wasm/universal`
package and implement the `UniversalPHP` interface that standardizes the API across
all PHP environments.

### 󠀁[Loading the PHP runtime](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#loading-the-php-runtime)󠁿

The load() method handles the entire PHP initialization pipeline. In particular,
it:

 * Instantiates the Emscripten PHP module
 * Wires it together with the data dependencies and loads them
 * Ensures is all happens in a correct order
 * Waits until the entire loading sequence is finished

First published

July 15, 2026

Last updated

July 16, 2026

Edit article

[ Improve it on GitHub: PHP.js JavaScript module ](https://raw.githubusercontent.com/WordPress/wordpress-playground/trunk/packages/docs/site/docs/developers/23-architecture/04-wasm-php-javascript-module.md)

Changelog

[ See list of changes: PHP.js JavaScript module ](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/?output_format=md#)

[  Previous: Compiling PHP](https://developer.wordpress.org/playground/developers/architecture/wasm-php-compiling/)

[  Next: PHP Filesystem](https://developer.wordpress.org/playground/developers/architecture/wasm-php-filesystem/)