r/PHP • • 4d ago

php-wasm-builder 1.0: compile PHP to WebAssembly, with your extensions and your code, and run it in the browser

https://blog.lyrixx.info/posts/php-wasm-builder-1-0-is-out/
19 Upvotes

11 comments sorted by

4

u/lyrixx86 4d ago

Author here! I needed PHP in the browser for a few tools (composer-diff, an emoji converter), so I forked Derick Rethans' builder to compile any PHP version, with any extensions, and your own code inside.

1.0 means it follows SemVer from now on. The demos run with no PHP server, only static files on GitHub Pages:

Docs: https://lyrixx.github.io/php-wasm-builder/

Feedback welcome, I'd love to know what you would build with it!

3

u/lam_42 4d ago

How large a footprint does it leave?

5

u/lyrixx86 4d ago

It depends on what you ship. For a regular PHP: 3Mb gziped you can get more data on this page https://lyrixx.github.io/php-wasm-builder/reference/sizes/

4

u/lam_42 4d ago

That is pretty minuscule considering how heavy pages tend to be nowadays...

2

u/Bellargent_Moulida 4d ago

static hosting for live admin panel demos makes way more sense than maintaining a shared sandbox server where people constantly wipe the demo data

1

u/r-spriebsch 3d ago

That's quite cool, thanks for sharing!

0

u/Jebus-san91 4d ago

An old colleague once said when this released we could finally replace JavaScript..... Is it true? Has the day come

3

u/lyrixx86 4d ago

nope, you need JS as entrypoint to load the WASM :) but you can do a lot of things in WASM/PHP after that !

-6

u/Professional_Tune_82 4d ago

Just rewrite to rust 🫠

1

u/lyrixx86 4d ago

What? All the PHP libs? One day, one day... I miss some time right now!

But in the meantime, there is this bridge !

0

u/Professional_Tune_82 4d ago edited 4d ago

Was just a bad joke 😅

But hey if you want it https://phprust.com/