Git Product home page Git Product logo

Comments (20)

mho22 avatar mho22 commented on June 15, 2024 2

@adamziel I tried removing --disable-all and recompiled only in 8.3 but an error occurred quickly. opcache was responsible of that error. I then added --disable-opcache and the recompilation of 8.3 succeeded.

I ran a npm run php -m to list the available php-wasm extensions and two new extensions appeared :

  • fileinfo
  • posix

I suppose this could be the solution. I am currently busy recompiling every PHP versions before launching the tests.

By the way, I was wondering : could there be a way to make --with-curl work for php-wasm ?

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024 2

Concerning --with-curl do you mind if I add it to php-wasm ? Or you suggested me doing this locally ?

@mho22 I would be stoked to have this in php-wasm, you would enable a lot of developers to explore new use-cases and run their code in Playground 🔥

If you can get it to build, this PR should give curl access to the network.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024 1

@adamziel Alright, I'm working on it.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024 1

There are also two WITH_ICONV for node build. I suppose I can "clean" this ?

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024 1

@adamziel Only one test failed at this point :

FAIL  src/lib/steps/wp-cli.spec.ts > Blueprint step wpCLI > should run wp-cli commands
    AssertionError: expected '#!/usr/bin/env php\n' to match /Success: Created post/
        ❯ src/lib/steps/wp-cli.spec.ts:35:23

The expected value is too specific to be a "real" error. I suppose the result.text returns the first line of the file here #!/usr/bin/env php\n instead of the result that could possibly be /Success: Created post/.

But I will wait for your insight about this.

Anyways, this sounds promising I suppose. Let's make the Pull Request now.

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024 1

Aha! I'd go to http://localhost:5400/website-server/, load the PHP version you've rebuilt, and run this in the dev tools:

document.body.innerHTML = (await playground.run({ code: `<?php phpinfo(); ?>` })).text

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

Oh interesting! Are we missing a php.ini setting? Or perhaps the --disable-all flag during the compilation removes this extension from the build?

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

@adamziel Do you know a way for me to help find how to solve this ?

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

@mho22 yes! One way would be to compare the phpinfo() output at https://playground.wordpress.net/?url=/phpinfo.php with a regular PHP installation that has that class and figure out what's different with respect to the finfo class. I think we need to add a flag to ./configure call that would be similar to --enable-finfo. I'm not sure what the exact name is, there should be some hints in https://github.com/php/php-src/tree/master/ext/fileinfo and https://github.com/php/php-src/ in general.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

@adamziel I suppose two screenshots with PHP8.2 binary phpinfo() method and PHP-WASM8.2 phpinfo() could be interesting to view here but these views are gigantic.

So, here is a little screenshot of the only thing different when I search for finfo or fileinfo between the two. This element appears on PHP8.2 binary, not PHP-WASM8.2.

Capture d’écran 2024-03-21 à 23 25 00

Next is the data from Configure Command. I think the best would be to paste what I have. And I hope this will be readable enough :

PHP8.2 binary:

'./configure' '--prefix=/usr/local/Cellar/[email protected]/8.2.14' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/8.2' '--with-config-file-path=/usr/local/etc/php/8.2' '--with-config-file-scan-dir=/usr/local/etc/php/8.2/conf.d' '--with-pear=/usr/local/Cellar/[email protected]/8.2.14/share/[email protected]/pear' '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-gd' '--enable-intl' '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd' '--enable-pcntl' '--enable-phpdbg' '--enable-phpdbg-readline' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-apxs2=/usr/local/opt/httpd/bin/apxs' '--with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-curl' '--with-external-gd' '--with-external-pcre' '--with-ffi' '--with-fpm-user=_www' '--with-fpm-group=_www' '--with-gettext=/usr/local/opt/gettext' '--with-gmp=/usr/local/opt/gmp' '--with-iconv=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-kerberos' '--with-layout=GNU' '--with-ldap=/usr/local/opt/openldap' '--with-libxml' '--with-libedit' '--with-mhash=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-ndbm=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-openssl' '--with-password-argon2=/usr/local/opt/argon2' '--with-pdo-dblib=/usr/local/opt/freetds' '--with-pdo-mysql=mysqlnd' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--with-pdo-pgsql=/usr/local/opt/libpq' '--with-pdo-sqlite' '--with-pgsql=/usr/local/opt/libpq' '--with-pic' '--with-pspell=/usr/local/opt/aspell' '--with-sodium' '--with-sqlite3' '--with-tidy=/usr/local/opt/tidy-html5' '--with-unixODBC' '--with-xsl' '--with-zip' '--with-zlib' '--enable-dtrace' '--with-ldap-sasl' '--with-os-sdkpath=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk' 'PKG_CONFIG_PATH=/usr/local/opt/apr/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig:/usr/local/opt/apr-util/lib/pkgconfig:/usr/local/opt/argon2/lib/pkgconfig:/usr/local/opt/brotli/lib/pkgconfig:/usr/local/opt/libidn2/lib/pkgconfig:/usr/local/opt/libnghttp2/lib/pkgconfig:/usr/local/opt/libssh2/lib/pkgconfig:/usr/local/opt/openldap/lib/pkgconfig:/usr/local/opt/rtmpdump/lib/pkgconfig:/usr/local/opt/lz4/lib/pkgconfig:/usr/local/opt/xz/lib/pkgconfig:/usr/local/opt/zstd/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/unixodbc/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/freetype/lib/pkgconfig:/usr/local/opt/fontconfig/lib/pkgconfig:/usr/local/opt/jpeg-turbo/lib/pkgconfig:/usr/local/opt/highway/lib/pkgconfig:/usr/local/opt/imath/lib/pkgconfig:/usr/local/opt/libtiff/lib/pkgconfig:/usr/local/opt/little-cms2/lib/pkgconfig:/usr/local/opt/openexr/lib/pkgconfig:/usr/local/opt/webp/lib/pkgconfig:/usr/local/opt/jpeg-xl/lib/pkgconfig:/usr/local/opt/libvmaf/lib/pkgconfig:/usr/local/opt/aom/lib/pkgconfig:/usr/local/opt/libavif/lib/pkgconfig:/usr/local/opt/gd/lib/pkgconfig:/usr/local/opt/gmp/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/libpq/lib/pkgconfig:/usr/local/opt/libsodium/lib/pkgconfig:/usr/local/opt/libzip/lib/pkgconfig:/usr/local/opt/oniguruma/lib/pkgconfig:/usr/local/opt/pcre2/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/sqlite/lib/pkgconfig:/usr/local/opt/tidy-html5/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.15' 'KERBEROS_CFLAGS= ' 'SASL_CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sasl' 'SASL_LIBS=-lsasl2'

PHP-WASM8.2 :

'./configure' 'PKG_CONFIG_PATH=/root/lib/lib/pkgconfig' '--disable-fiber-asm' '--enable-json' '--enable-embed=static' '--with-layout=GNU' '--disable-cgi' '--disable-all' '--enable-hash' '--enable-static=yes' '--enable-shared=no' '--enable-session' '--enable-filter' '--enable-calendar' '--disable-rpath' '--disable-phpdbg' '--without-pear' '--with-valgrind=no' '--without-pcre-jit' '--enable-bcmath' '--enable-ctype' '--enable-tokenizer' '--with-zlib' '--with-zlib-dir=/root/lib' '--with-zip' '--enable-phar' '--enable-cli=static' '--enable-readline' '--with-libedit=/root/lib' '--enable-libxml' '--with-libxml' '--with-libxml-dir=/root/lib' '--enable-dom' '--enable-xml' '--enable-simplexml' '--enable-xmlreader' '--enable-xmlwriter' '--with-sqlite3' '--with-pdo-sqlite=/root/lib' '--with-png-dir=/root/lib' '--with-gd' '--enable-gd' '--with-openssl' '--with-openssl-dir=/root/lib' '--with-iconv=/root/lib' '--enable-mbstring' '--disable-mbregex' '--enable-mysql' '--enable-pdo' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' 'PKG_CONFIG_LIBDIR=/root/emsdk/upstream/emscripten/cache/sysroot/local/lib/pkgconfig:/root/emsdk/upstream/emscripten/cache/sysroot/lib/pkgconfig'

Now is time to investigate.

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

This could be relevant:

https://github.com/php/php-src/blob/530e0d68ebee5b21ad10311115c392072b8b4168/ext/fileinfo/config.m4#L1-L5

I'm not sure if --disable-all impacts that flag at all.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

It seems like --disable-all disables all extensions which are enabled by default :

https://github.com/php/php-src/blob/530e0d68ebee5b21ad10311115c392072b8b4168/configure.ac#L1099

This does not confirm that it disables fileinfo either.

That said, I can't find anything about "re-enable" disabled default extensions, like :

--disable-all
--enable-fileinfo
--enable-curl

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

Perhaps it's time to remove --disable-all and tactically disable specific extensions instead, then.

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

Lovely! 🤞it will just work for all the PHP versions :)

About curl, you’d need to add libcurl directory here and provide a wasm build of the library:

https://github.com/WordPress/wordpress-playground/tree/trunk/packages/php-wasm/compile

From there, you could add —with-curl to ./configure in the same way as other extensions are provided.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

@adamziel It seems when i npm run recompile:php:web I get the given error :

#38 34.22 configure: error: iconv does not support errno

And this has been said about that :

As of PHP 8.0.0, iconv implementation which do not support errno
(i.e. non POSIX conforming implementations) are no longer
supported.

https://bugs.php.net/bug.php?id=80585

I added this :

# Add iconv if needed
RUN if [ "$WITH_ICONV" = "yes" ]; \
	then \
		echo -n ' --with-iconv=/root/lib ' >> /root/.php-configure-flags; \
		echo -n ' /root/lib/lib/libiconv.a' >> /root/.emcc-php-wasm-sources; \
		# PHP >= 8.0 posix is no longer supported.
		# PHP ≤= 7.4 posix is supported.
		if [[ "${PHP_VERSION:0:1}" -ge "8" ]]; then \
			echo -n ' --disable-iconv ' >> /root/.php-configure-flags; \
		fi; \
	fi;

Not working at the moment. Anyways, I am on it.

Concerning --with-curl do you mind if I add it to php-wasm ? Or you suggested me doing this locally ?

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

@mho22 aha, WITH_ICONV is only set to yes for the kitchen-sink build but not for the light build. without the --disable-all that part of the DOCKERFILE might need a top-level else as follows:

RUN if [ "$WITH_ICONV" = "yes" ]; \
	then \
		echo -n ' --with-iconv=/root/lib ' >> /root/.php-configure-flags; \
		echo -n ' /root/lib/lib/libiconv.a' >> /root/.emcc-php-wasm-sources; \
		# PHP >= 8.0 posix is no longer supported.
		# PHP ≤= 7.4 posix is supported.
	else \
		echo -n ' --disable-iconv ' >> /root/.php-configure-flags; \
	fi;

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

@adamziel It seems npm run recompile:php:web:light:8.3 [ who has no WITH_ICONV enabled ] kept throwing :

#38 34.22 configure: error: iconv does not support errno

I added --without-iconv and there was no iconv error anymore. Instead, I had :

44.14 checking whether to enable XMLReader support... yes
44.14 configure: error: XMLReader extension requires LIBXML extension, add --with-libxml

So I added --disable-xmlreader in the RUN if [ "$WITH_LIBXML" = "yes" ]; else [ it seemed to be missing ].

I also tried by removing --disable-iconv and it worked too. I suppose this is correct.

Running every recompile and then testing. Let's find out if everything works fine. I keep you posted.

P.S.: I am glad to hear that lib-curl could probably be added, but I should mention that I will try to add it. I am absolutely not confident in my success.

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

@adamziel I am trying to list the PHP extensions from @php-wasm/web but this code gives me a module error :

npm install @php-wasm/web

index.js

import { WebPHP } from '@php-wasm/web';

const php = await WebPHP.load( '8.3' );

php.writeFile( '/index.php', `<?php echo phpinfo(); ?>` );

await php.run( { scriptPath : './index.php' } );

node index.js

node:internal/modules/esm/get_format:160
  throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
        ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm" for /wasm/node_modules/@php-wasm/web/light/8_3_0/php_8_3.wasm
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:403:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v21.7.1

I am probably missing something obvious. But I need some enlightenments.

I tried this :

node --experimental-wasm-modules index.js

(node:67155) ExperimentalWarning: Importing WebAssembly modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/modules/esm/resolve:845
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'a' imported from /Users/mho/Work/Sandbox/Web/php/php-wasm/wasm/node_modules/@php-wasm/web/light/8_3_0/php_8_3.wasm
    at packageResolve (node:internal/modules/esm/resolve:845:9)
    at moduleResolve (node:internal/modules/esm/resolve:918:18)
    at defaultResolve (node:internal/modules/esm/resolve:1148:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v21.7.1

from wordpress-playground.

adamziel avatar adamziel commented on June 15, 2024

@php-wasm/web is meant to be used in web browsers. Perhaps @php-wasm/browser would be a better package name. What you're looking for is likely:

import { NodePHP } from '@php-wasm/node';

from wordpress-playground.

mho22 avatar mho22 commented on June 15, 2024

Yeah, that was indeed obvious. Apologies for the silly question. I should probably ask you what the quickest way is to list the PHP extensions of php-wasm/web/light using the '@php-wasm/web' package instead.

In other words, how can I list the php extensions present in the light version when I recompile it and rebuild it ?

from wordpress-playground.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.