Skip to content

No server. Just a page.

PHP
in the browser

PHP WASM Builder compiles PHP to WebAssembly, with the PHP version and the extensions you ask for, and your code in it. A page runs it with a few lines of JavaScript, and node runs it too.

Get started Use it in your project

Zero servers

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

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

Hello from PHP 8.5.12

Three steps, no server

Build PHP

Docker compiles PHP to WebAssembly: the version, and the extensions you ask for.

docker buildx bake

Embed your code

Your code, and its vendor/, go in the .wasm file, where PHP finds them.

EMBED_AT=/app

Run it

In a page, in a Web Worker, or in node. Files can stay across reloads.

php.runFile('/app/index.php')

Examples

They run in your browser, right now. Their code is in examples/, a directory each.

PHP playground

Write PHP, and run it in the browser, with every extension that the builder supports.

PHP 8.5.12, 7.2 MB to download

Symfony, in the browser

A Symfony application, with Doctrine and SQLite, forms and a session, in a frame: what you write is still there after a reload.

PHP 8.5.12, 7.2 MB to download

Built with it

These pages run PHP in the browser, built with PHP WASM Builder.

composer-diff

Compares two composer.lock.

public/page.mjs runs PHP

emoji-converter

Turns 🐘 into :elephant:, and back.

website/public/js/php.js runs PHP

JoliTypo

Fixes the microtypography of an HTML text.

website/public/js/php.js runs PHP

Your turn

docker buildx bake

Get started Read the JavaScript API