Custom Builds with php-wasm-builder
The php-wasm-builder package is the set
of source files needed to build php-wasm & php-cgi-wasm.
The php-wasm-builder command is a
wrapper script for the build process that allows the user to
easily configure the underlying build process & drop the
build assets wherever is necessary.
You can use .php-wasm-rc to customize your build.
Installing php-wasm-builder
Install php-wasm-builder globally:
Requires: * Docker * Docker Compose * Coreutils * Wget * Make
$ npm install -g php-wasm-builderCreate the build environment (can be run from anywhere):
$ php-wasm-builder imageClean up files from a previous build
(Usually needed if the PHP version changes or Emscripten ABI changes have occurred)
$ php-wasm-builder cleanphp-wasm-builder commands
build
Use this to build custom version of php-wasm. It’s
recommended to build this to an empty directory using a
.php-wasm-rc file.
npx php-wasm-builder buildimage
This will build the docker container used to build php-wasm.
npx php-wasm-builder imagecopy-assets
This will scan the current package’s node_modules directory
for shared libraries & supporting files, and copy them to
PHP_ASSET_DIR.
You can use this with .php-wasm-rc to copy
assets even if you’re not using a custom build.
npx php-wasm-builder copy-assetsbuild-assets
While copy-assets moves existing shared
libraries, the build-assets command compiles them
first, then moves them to PHP_ASSET_DIR.
You can use this with .php-wasm-rc to copy
assets even if you’re not using a custom build.
npx php-wasm-builder build-assetsclean
Clear cached build resources.
npx php-wasm-builder cleandeep-clean
Clear out all downloaded dependencies and start from scratch.
npx php-wasm-builder deep-cleanhelp
Print the help text for a given command
npx php-wasm-builder help COMMANDBuild for web
Then navigate to the directory you want the files to be built
in, and run php-wasm-builder build
$ cd ~/my-project
$ php-wasm-builder build
# "web" is the default:
# php-wasm-builder build webBuild for node
$ cd ~/my-project
$ php-wasm-builder build nodeESM Modules:
Build ESM modules with:
$ php-wasm-builder build web mjs
$ php-wasm-builder build node mjsCGI Modules:
Build CGI modules with:
$ php-wasm-builder build web cgi mjs
$ php-wasm-builder build worker cgi mjsPHP_DIST_DIR
This will build the package inside of the current directory
(or in PHP_DIST_DIR, see .php-wasm-rc for more
info.)