phan / demo Goto Github PK
View Code? Open in Web Editor NEWRun phan entirely in your browser (with emscripten)
Home Page: https://phan.github.io/demo/
License: MIT License
Run phan entirely in your browser (with emscripten)
Home Page: https://phan.github.io/demo/
License: MIT License
hello, first of all, I'm sorry because this may not be an actual issue and it's kinda offtopic.
I've been trying to compile PHP 8.1 for WASM for a few weeks now and haven't had much luck. I recently came across this repo and noticed you managed to do it.
I've cloned your repo locally and tried to do the compile myself, and when I try to run code in the demo app it works but fails for more complex code snippets (like including the phan phar or its autoload.php, or a deeply recursive function) - those same code snippets work when I just download your compiled php.wasm, php.data and php.js from https://phan.github.io/demo/ and load them locally or even in the online demo app.
The error I'm getting when trying to run the complex code (sometimes in the output section in page and sometimes in console):
Unexpected error reloading php: RangeError: Maximum call stack size exceeded
I then proceeded to modify the build.sh - get rid of most extensions and change the compile flags in attempts to get it to work but with no success and I've done over a hundred different compiles at this point.
If anyone's interested to help me out, here are the important parts of my build.sh:
export CFLAGS='-O1 -DZEND_MM_ERROR=0'
./buildconf --force
emconfigure ./configure \
--with-layout=GNU \
--enable-embed=static \
--disable-all \
--disable-cgi \
--disable-cli \
--disable-rpath \
--disable-phpdbg \
--without-pear \
--without-pcre-jit \
--without-valgrind \
--with-valgrind=no \
--disable-fiber-asm \
--enable-phar
emmake make clean
emmake make -j5
emcc $CFLAGS -I . -I Zend -I main -I TSRM/ ../pib_eval.c -c -o pib_eval.o
emcc $CFLAGS \
--llvm-lto 2 \
-s ENVIRONMENT=web \
-s EXPORTED_FUNCTIONS='["_pib_eval", "_php_embed_init", "_zend_eval_string", "_php_embed_shutdown"]' \
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall"]' \
-s MODULARIZE=1 \
-s EXPORT_NAME="'PHP'" \
-s TOTAL_MEMORY=134217728 \
-s INVOKE_RUN=0 \
-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
-s ASSERTIONS=1 \
-s TOTAL_STACK=10485760 \
--preload-file some.phar \
libs/libphp.a pib_eval.o -o out/php.js
I'm running Emscripten SDK version 1.39.18 with the following command:
docker run --rm -v $(pwd):/src trzeci/emscripten /bin/bash -c "apt-get update ; apt-get install -y autoconf ; ./build.sh"
thanks very much in advance to anyone who's willing to help regarding this.
I'd love to fork this demo to provide an online demo for the taint-check plugin. All I'd need is basically be able to use a different config for running phan. AFAICS it should be doable if I just change the content of #phan_runner_source and adjust it to my needs, although that seems fragile. Is there a recommended way for my use case, or should I just go ahead with the above?
The header says
Uses Phan 4.0.0 and PHP 8.0.0
And this seems to be correct, if I run this code:
<?php
function baz() {
$val = match ( 'foo' ) {
'foo' => 'v1',
'bar' => 'v2'
};
echo $val;
}
baz();
it yields the expected output (link)
However, the ace editor isn't validating the code against PHP 8, because it displays a syntax error on line 5.
https://groups.google.com/forum/#!topic/ace-discuss/joAFrXwWLX8
This should use different classes, and clear errors when the file gets changed
var Range = ace.require('ace/range').Range;
editor.session.addMarker(new Range(8, 0, 8, 1), "ace_highlight-marker", "fullLine");
Do this before preloading webassembly code, await confirmation https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API (experimental)
This might be useful for local setups (e.g. against an internal codebase)
E.g. run internal/dump_fallback_ast.php
, optionally with styled output.
Make it possible to link to the ASTs that would be generated for a given PHP snippet.
This would make switching to older phars or other tools more convenient
Compare with https://play.rust-lang.org/ , which has
Fatal errors aren't handled by regular error handlers. I tried patching php-src/main/main.c to support logging them to stderr, but this isn't working as intended.
Seen when clicking RUN on snippets such as:
<?php
class X {}
class X {}
If it does, it would avoid the need to recompile the wasm code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.