WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.62k stars 249 forks source link

Blueprints: Transition from a TypeScript library to a PHP library #1025

Open adamziel opened 7 months ago

adamziel commented 7 months ago

Let’s pivot Blueprints from a TypeScript library to a PHP library. I started the explorations in this repo:

https://github.com/WordPress/blueprints/

Motivation

PHP Blueprints would unite all the Blueprint runtime environments, use-cases, and developers. Single library and documentation unlocking multiple ecosystems.

PHP-powered Blueprints would:

Blueprints would become the lingua franca of WordPress. All the runtimes would rely on the same orchestration library:

Here's a few specific use-cases I have in mind

Technical steps to get there

Here's the big picture of what we'll need to do:

  1. Disregard WASM and prototype a PHP library that only works well in native PHP. Don't overuse third party libraries, but rely on small components like Symfony EventDispatcher when applicable.
  2. Run that library in PHP.WASM, identify all the ways it fails.
  3. Bundle the library as phar, explore using it in WordPress, WordPress Playground plugin, wp-now, wp-cli etc.
  4. Outline a plan to make it work with the least amount of work. Use workarounds, adjust the PHP library, adjust PHP.wasm implementation, and build polyfills as needed.
  5. Outline a plan to replace all the workarounds with stable, long-term, easy-to-maintain solutions.
  6. Bring the phar library into WordPress Playground core, make the @wp-playground/blueprints library a thin wrapper that delegates all the tasks to the PHP implementation

Related and known PHP.wasm limitations

Other notes

cc @bgrgicak @dmsnell @mtias @youknowriad @eliot-akira @sejas @danielbachhuber

adamziel commented 7 months ago

Surfacing these relevant explorations: