Node.js で WordPress Playground を使用する
WebAssembly プロジェクトとして、Node.js で WordPress Playground を使用することもできます。
WebAssembly PHP ビルドの基盤となる低レベルの制御が必要な場合は、PHP WebAssembly ランタイムを同梱する @php-wasm/node
パッケージ をご覧ください。このパッケージは、Node.js 向けのすべての WordPress Playground ツールの中核を成しています。
API リファレンス
クラス、関数、インターフェース、および型エイリアスの完全なリストを参照してください。
WebAssembly PHP for Node.js
This package ships WebAssembly PHP binaries and the JavaScript API optimized for Node.js. It comes with the following PHP extensions:
- SQLite
- Libzip
- Libpng
- CLI
- OpenSSL
- MySQL
It uses the host filesystem directly and can access the network if you plug in a custom WS proxy.
Here's how to use it:
import { PHP } from '@php-wasm/universal';
import { loadNodeRuntime } from '@php-wasm/node';
const php = new PHP(await loadNodeRuntime('8.3'));
const output = await php.run({
code: '<?php phpinfo(); ?>',
});
console.log(response.text);
Attribution
@php-wasm/node
started as a fork of the original PHP to WebAssembly build published by Oraoto in https://github.com/oraoto/pib and modified by Sean Morris in https://github.com/seanmorris/php-wasm.