WASM examples in the manual

[email protected] (Derick Rethans) Tue, 11 Feb 2025 10:06:17 +0000 (GMT)
Newsgroups php.doc
Message-ID <[email protected]>
Hi,

Some time ago, we added a WASM runner to the manual, to run examples. 
All examples have it added. However, not all of them work.

I've been investigating examples and running them with WASM. First how 
to build a new WASM file (https://github.com/derickr/php-wasm-builder), 
and to see how we can add extensions.

Extensions all need to be compiled separately as static libraries.

I've done that for the XML extensions 
and mbstring, which increases the WASM PHP binary from 2.7 to 8.5MB.

Secondly, I have created a script that extracts all the 
examples and runs them through a separate WASM binary (that I can use 
with node) to see if the examples:

 a. run (think syntax errors);
 b. hang; 
 c. are missing extensions.

There are going to be a lot of them where having WASM enabled for them 
don't make a lot of sense. Especially for category "c". And the category 
"b" ones just sit there eat CPU cycles.

Now my question is, should we specifically mark examples (using 
<programlisting role="php" annotations="interactive">) or rather mark 
them as not runnable (think <programlisting role="php" 
annotations="no-wasm">. I am thinking rather the former than the latter, 
as there will be so many that won't run (due to missing extensions, 
mostly).

I'm inclined to make this opt-in (by havin to add the 'annotations' 
attribute. What do you think?

I do have a patch for this coming up, and also one to upgrade the WASM 
PHP version from 8.4.0-dev to 8.4.3.

cheers,
Derick

-- 
https://derickrethans.nl | https://xdebug.org | https://dram.io

Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support

mastodon: @[email protected] @[email protected]