-
Notifications
You must be signed in to change notification settings - Fork 295
Support multiple PHP versions #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds support for the `php` query string option that may be used to switch between PHP versions. For example: /wordpress.html?php=8.1 Supported versions: 8.0, 8.1, 8.2
Problems with this PR:
Edit: Both issues are now addressed |
Closed
This one is ready! |
bgrgicak
added a commit
that referenced
this pull request
May 7, 2025
## Motivation for the change, related issues This PR adds `statfs` support to the Emscripten root file system to enable PHP-wasm Node to get real filesystem stats for the `/` path. Currently, in PHP-wasm Node, PHP functions like `disk_total_space('/')` return the default hardcoded value for MEMFS instead of the actual disk space. This happens because Emscripten automatically detects the filesystem for a given path, and because the root path always uses the MEMFS filesystem, Emscripten will use the MEMFS `statfs` implementation. PHP-wasm Node includes two Emscripten filesystems, MEMFS and NODEFS. MEMFS doesn't have access to the operating system's filesystem, so it can only return a hardcoded value. NODEFS has access to the OS filesystem through the `fs` module, and specifically for `statfs` it uses `fs.statfsSync` to get real data. ## Implementation details This PR uses Emscripten's `onRuntimeInitialized` event to override the `statfs` implementation in the Emscripten root FS with the NODEFS implementation of `statfs`. It also defines the `FS.root.mount.opts.root` path as `.` to ensure the root node has a path value defined. Otherwise when we call `FS.statfs('/')` it would use the root node's root path which is `undefined` and this would throw an error because it would call `fs.statfsSync(undefined)` in the NODEFS implementation of `statfs`. I explored fixing this [issue in Emscripten](emscripten-core/emscripten#23912), but I wasn't able to find a working solution there, so I ended up patching it in Playground. ## Testing Instructions (or ideally a Blueprint) - CI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds support for more PHP versions and a
php
query parameter to switch between them. For example:/wordpress.html?php=5.6
:Supported PHP versions: 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2