Skip to content
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

[Web] Ship additional .wasm bundles with more PHP extensions #655

Closed
Mte90 opened this issue Oct 5, 2023 · 13 comments
Closed

[Web] Ship additional .wasm bundles with more PHP extensions #655

Mte90 opened this issue Oct 5, 2023 · 13 comments
Labels

Comments

@Mte90
Copy link

Mte90 commented Oct 5, 2023

In case of our plugin Glossary we need the mbstring and iconv available.

You can see the plugin warning on https://playground.wordpress.net/?plugin=glossary-by-codeat&login=1&url=/wp-admin/plugins.php

Also a list in the doc of the PHP modules used by the tool can be useful for this things

@BenSibley
Copy link

We have the same issue with our plugin. It needs both the iconv and mbstring extensions. The playground should include widely used modules like these.

@adamziel
Copy link
Collaborator

adamziel commented Oct 6, 2023

Thank you for reporting @Mte90! mbstring is already supported, just not shipped with the web version of Playground. @akirk suggested shipping additional wasm bundles with more PHP extensions for the plugins that need that. Let's make this issue all about that.

There could be 3 bundles:

  1. Vanilla PHP as it is now
  2. PHP + iconv, mbstring
  3. PHP + all supported extensions (openssl, libxml, libcurl in the future)

Then, Playground would need to accept a list of PHP extensions and choose an appropriate bundle. This would affect the following APIs:

  • Query string (&extension=iconv&extension=mbstring
  • Blueprints ("extensions": ["iconv", "mbstring])
  • JavaScript API (PHP.load("8.0", {"extensions": ["iconv", "mbstring]});

iconv is not supported yet and would need some explorations. I just created issue #666 to track it.

@adamziel adamziel changed the title Add PHP modules [Web] Ship additional .wasm bundles with more PHP extensions Oct 6, 2023
@Mte90
Copy link
Author

Mte90 commented Oct 10, 2023

Why not ship just a single playground version with all the php modules?

@adamziel
Copy link
Collaborator

adamziel commented Oct 10, 2023

@Mte90 I'd love to do that! The problem is with the bundle size – the minimal playground build for the web is 6MB at the time, while the Node.js build that has more extensions is about ~11MB. With more extensions, that figure is only going to grow, but modularity would allow us to only download what's needed. I'm currently exploring modular extension loading in #314.

@Mte90
Copy link
Author

Mte90 commented Oct 10, 2023

It make sense but we are talking about a playground that is used by desktop and not mobile so downloading is not a big problem (compared to mobile).
Also because for the plugin repository is not something easy as plugins not define anyway what are the php module that use it, everyone has custom code for that.

@adamziel
Copy link
Collaborator

adamziel commented Oct 10, 2023

@Mte90 I didn't mean that as a blocker. Shipping an additional "all included" bundle for the plugin directory sounds reasonable to me until there is a modular solution. The preview in the plugin repository will be an opt-in feature and offer a convenient way for plugin authors to define the required PHP extensions. Whether the default option should be a "minimal" PHP build or an "all included" build is a separate conversation and would be a good fit for https://meta.trac.wordpress.org/ticket/7251.

adamziel added a commit that referenced this issue Oct 12, 2023
Adds support for loading arbitrary PHP extensions in the web version of
Playground using all three available APIs:

* Query API: `?php-extension-bundle=kitchen-sink`
* Blueprints: `{ "phpExtensionBundles": [ "kitchen-sink" ] }`

For now, it only switches between a barebones ~6MB PHP build and a
larger ~8MB with more extensions included. In the future, the internal
implementation will change and PHP extensions will be shipped and
downloaded separately – see
#673

1. Click the new "Load PHP extensions" checkbox in the configuration
modal
2. Go to /phpinfo.php and confirm that `gd`, `xml`, and `mbstring`
extensions are now available
3. Uncheck that checkbox
4. Confirm these extensions are no longer loaded

<img width="1251" alt="CleanShot 2023-10-11 at 19 50 14@2x"
src="https://github.com/WordPress/wordpress-playground/assets/205419/4f341a98-6a3a-4b01-b406-03d3e2834a20">

Solves #655

cc @dmsnell @danielbachhuber @seanmorris
@tbradsha
Copy link

tbradsha commented Dec 8, 2023

Lack of OpenSSL support is currently a blocker for our plugin in WordPress Playground; looking forward to more PHP extensions being supported!

@adamziel
Copy link
Collaborator

adamziel commented Dec 9, 2023

@tbradsha Thank you for letting us know! Solving this issue is slowly becoming possible, especially after the recent merge of #838. Is your plugin publicly available? How are you using OpenSSL in it? I'm asking because the current level of network support doesn't enable use-cases like e.g. downloading SSL certificates, see #85

@tbradsha
Copy link

Indeed, you can search the WP.org repo for Jetpack CRM. We primarily use OpenSSL to encrypt/decrypt sensitive data.

adamziel added a commit that referenced this issue Dec 19, 2023
…883)

## What is this PR doing?

Related to #655

Includes the OpenSSL PHP extension in the `kitchen-sink` extension
bundle. This also makes it available via the "Load extensions" checkbox
on playground.wordpress.net.

## Testing instructions

1. Apply this PR
2. Open Playground and go to /phpinfo.php
3. Confirm the OpenSSL extension is listed as available
@adamziel
Copy link
Collaborator

adamziel commented Feb 3, 2024

Playground now supports an "all available PHP extensions" bundle via the kitchen-sink extensions bundle:

CleanShot 2024-02-03 at 22 54 15@2x

Blueprints API:

{
    "phpExtensionBundles": ["kitchen-sink"]
}

Query API:

?php-extension-bundle=kitchen-sink

@adamziel adamziel closed this as completed Feb 3, 2024
@Mte90
Copy link
Author

Mte90 commented Feb 6, 2024

There is a way to load them without the modal itself? like with a URL or something in the readme?

@adamziel
Copy link
Collaborator

adamziel commented Feb 6, 2024

Yeah, see the Query API and Blueprints API in my reply. Here's how you'd use them:

Query API:

https://playground.wordpress.net/?php-extension-bundle=kitchen-sink

Blueprints API:

https://playground.wordpress.net/#{"phpExtensionBundles":["kitchen-sink"]}

@Mte90
Copy link
Author

Mte90 commented Feb 6, 2024

Ah ok sorry I didn't understood that kitchen-sink is just a placeholder for a php module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants