Search by

lyrixx / php-wasm-builder

lyrixx

Builds PHP as WebAssembly: a Dockerfile, and a castor function to build stacks (a PHP version, extensions, what to embed) with one command

Package info

github.com/lyrixx/php-wasm-builder

Language:JavaScript

pkg:composer/lyrixx/php-wasm-builder

Statistics

Installs: 216

Dependents: 0

Suggesters: 0

Stars: 10

Open Issues: 0

v0.12.2 2026-11-05 18:51 UTC

README

Builds PHP as WebAssembly, for the browser and for node, with the PHP version and the extensions you ask for, and the code you embed.

Try it

Docker builds PHP in build/php-8.5/, node runs it:

docker buildx bake
node node/run.mjs -r 'echo "Hello from PHP ", PHP_VERSION, "\n";'

A page imports php-web.mjs, and runs PHP:

<script type="module">
    import createPhp from './build/php-8.5/php-web.mjs';

    const php = await createPhp();
    const { stdout } = await php.runCode('echo PHP_VERSION;');
</script>

To build PHP for a page of your own, with your code, from your project: see Use it in your project.

Where things are

  • docker/: the Dockerfile that compiles PHP, and the JavaScript API of what it builds;
  • stacks.php: the builds that this repository checks, in CI too;
  • examples/: the examples of the website, a directory each, laid out as a project of your own would be: stack.php, public/, and app/;
  • docs/ and zensical.toml: the documentation, and the website;
  • CHANGELOG.md: what changes, that the website shows too;
  • castor.php and src/: the tasks that build, check and serve all of it, castor list lists them;
  • node/ and tests/: what runs PHP in node, and tests it.

Credits

This builder was created by Derick Rethans, for The PHP Foundation, in derickr/php-wasm-builder, the builder of the PHP WASM files of the php.net documentation. What runs PHP, docker/run.c, comes from the work of Antoine Bluchet. Both are under the MIT license, see LICENSE. The documentation thanks everyone else, see Credits.