Run Drupal on the edge in your browser with Web Assembly.
This utilizes php-wasm and php-cgi-wasm by Sean Morris.
Want to learn more? Catch my session Running Drupal on the Edge with Web Assembly at DrupalCon Barcelona.
PHP has been compiled into Web Assembly.
- The
php-wasm
package allows us to execute PHP code in the browser. - The
php-cgi-wasm
package allows us to execute PHP code in a service worker, which emulates CGI (think PHP-FPM), and allows serving requests to and from Drupal.
Using DDEV you can build and run the playground locally.
ddev start
ddev make build
Visit https://wasm-drupal.ddev.site
Currently this requires NPM, PHP (with Composer) on the host machine and Docker.
make build
make serve
Open http://localhost
Click Install for either Drupal or the Starshot prototype, and then wait for environment to launch.
Log in with
- Username:
admin
- Password:
admin
The goal is to split out the JavaScript from this project into a reusable package for others.
setup-cgi-worker.mjs
as an easy way to register the service worker for serving a Drupal applicationinstall-worker.mjs
as an easy way to install a Drupal application from an artifact
Use your browser's "Clear site data" functionality to perform a manual reset.
Visit chrome://serviceworker-internals/
- php-wasm does not provide an exposed function for running a specific script file, that means scripts like Composer and Drush cannot be directly invoked.
- php-wasm's SAPI name is
embed
, which breaks any code which checksPHP_SAPI === 'cli'
, such as Drush.