wasmer/wcgi-wordpress-demo

wasi

Public
wasmer run wasmer/wcgi-wordpress-demo

WCGI WordPress Demo

This demo contains a WordPress website that can be run as a WCGI program by Wasmer.

Getting Started

To run this demo, you will need to install the Wasmer toolchain.

$ curl https://get.wasmer.io -sSfL | sh -s "v3.2.0-beta.2"

(version v3.2.0-beta.2 or more recent is required).

You can use wasmer run-unstable to run the website locally.

$ wasmer run-unstable . --mapdir=/db:db
INFO run: wasmer_wasix::runners::wcgi::runner: Starting the server address=127.0.0.1:8000 command_name="php"

Hacks / Adaptations

This codebase does the following hacks to Wordpress to have it full running:

  • Replace exit; or die; to exit(0); or die(0);: they are equivalent, but they don't work without the arguments on the php-cgi WASI counterpart
  • Call echo " "; before exit as any header sent before an exit will be skipped if no body is being written

Replaced wp-includes/class-wp-http.php, wp-includes/class-wp-http-streams.php, wp-includes/class-wp-http-curl.php to return WP_Error;

public function request( $url, $args = array() ) {
  if (defined("IS_WASI") && IS_WASI) {
    return new WP_Error( 'http_request_failed', __( "The HTTP request to $url failed." ) );
  }
  // ...
}

Replaced _maybe_update_plugins in wp-includes/update.php:

function _maybe_update_plugins() {
  if (defined("IS_WASI") && IS_WASI) {
    return [
      "last_checked" => time() - 5,
    ];
  }
  // ...
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

A PHP Wordpress template for WCGI applications


Github
More packages
A PHP Wordpress template for WCGI applications
आयुष झा (Ayush Jha)
आयुष झा (Ayush Jha)
आयुष झा (Ayush Jha)
आयुष झा (Ayush Jha)
Javascript WCGI handler
A PHP template for WCGI applications
Wordpress starter package
A template for Rust WCGI applications