Run PHP in WASM?

Hello :wave:

With the rise of projects such as WordPress playground, and php-wasm. Do you think it might make more sense to run PHP on the client, to save server costs?

I Logged into Exercism today to find out if this was the model pivoted to, and found you’re still apparently using Docker and an older PHP version.

Why I think this is a good idea. Using caching headers, service-workers and a WASM-ified PHP, with a little work, a lot could be saved, and other types of exercise could be made possible.

PHP.net is using something similar as an example of live-docs

I made my own toy of this wanting multiple runtime versions, which I intend to use in my own notes for evergreen miro-labs

https://lewiscowles1986.github.io/experiments/wasm/php/

uses

GitHub - Lewiscowles1986/php-wasm-builder: A Dockerfile and shim to enable running PHP as WASM binary based from Derick Rethans own GitHub - derickr/php-wasm-builder: A Dockerfile and shim to enable running PHP as WASM binary (which I believe is used for PHP.net)

Challenges I foresee:

  • Decide if single static artifact or multiple artifact / request
  • Integrating PHPUnit
  • Saving and loading user code
  • re-writing / adding experiment flags to make all of this safe

Hi @Lewiscowles1986 and welcome to the Exercism forum!

I am one of the not-that-many PHP track maintainers. I experimented with WASM-PHP not that long ago, and yes, that seems to be a nice way to run PHP in the browser. But I also experienced the downside of it quickly: It all depends on very performant hardware on my side, and a really fast internet connection.

I stopped experimenting after I tried running a multifile project. There is a lot of work involved inventing things that already exist around the current Docker based solutions. Not just for WASM-PHP in general, but especially for Exercism. The JavaScript track is currently breaking grounds here (as the browser is a very capable JavaScript execution engine anyways), and the challanges don’t seem to end.

I, personally, do not have enough time and capacity to go along that path. As Exercism is based on volunteers making things happen, everybody is invited to work on a solution. I currently struggle to keep up with changes in Exercisms exercises and the surrounding infrastructure (like PHP, PHPUnit and the GitHub universe). There is still plenty of work left to do to have “a well maintained and up-to-date” track. I don’t see me being the leader in a technologically shift towards WASM-PHP.

1 Like

Hi mk-mxp, thank you for the insight. I should have really read this before responding in the python thread as hardware concerns around WASM are one of the largest blockers. I Take it, this being a volunteer effort we are not given data about the machine specs or capabilities of users?

I was very excited to see there seemed to be instructions on running locally. For me I started playing with PHP WASM just for a digital preservation piece, and then checked-in on Exercism and saw there are still financial pressures for the org, which is unfortunate.

I Will try to follow what the JS team are encountering, so if you have any links, that I may have missed, I’d be so very grateful.

Best

Could you expand on what you mean by this please? :slight_smile:

Hi @iHiD apologies I missed your reply. What I meant was:

Does Exercism have data about the specs of users machines?

I Combined this with a guess that:

Exercism does not; or at least does not publish such data.

In my attempt to be concise, I made my comment unclear and I’m sorry for that