php-wasm icon indicating copy to clipboard operation
php-wasm copied to clipboard

Add tag attribute for binding PhpWeb instance to window

Open jasalt opened this issue 6 months ago • 0 comments

Allows interactive debugging in browser console after page load which is not possible with the tag evaluation method as far as I understand.

Option 1 would simply look for "true" value and add binding window.php (available in browser console as php), option 2 allows user to specify binding name for avoiding naming conflicts e.g.

<script 
  type="text/php"
  data-stdout="div#output" data-stderr="pre#error"
  data-php-bind-window-as='wasmphp'>

Afterwards the instance can be called from JS console to inspect/modify filesystem contents await wasmphp.readdir('/preload/'), loaded classes await wasmphp.run('<?php echo print_r(get_declared_classes());') and so on.

The build / CI setup is foreign still, tested the patch locally on npm 0.0.9-alpha-32. Neater alternative solutions are welcome and attribute naming suggestions if this is generally a good idea.

jasalt avatar May 10 '25 07:05 jasalt