Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Aug 3, 2023
1 parent df6f763 commit a1f6061
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Expand Up @@ -11,18 +11,20 @@ I fixed some inconsistencies in the Makefile and removed non-essential things. T
- exposes FS and builds with [IDBFS](https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.syncfs)
- reduces memory to 256mb

## Usage
## Usage

Some build

## Build
## Build

```
docker pull soyuka/php-emscripten-builder
make
docker build . -t php-wasm
docker create --name=php-wasm php-wasm
docker cp php-wasm:/build/php-web.wasm ./build
docker cp php-wasm:/build/php-web.mjs ./build/php-web.mjs
```

Builded files will be located in `build/php-web.js` and `build/php-web.wasm`.
Builded files will be located in `build/php-web.js` and `build/php-web.wasm`.

## Usage

Expand Down Expand Up @@ -52,7 +54,7 @@ return phpBinary({
})
```

The builded PHP WASM version exposes these functions that will help you execute PHP: `_pib_init`, `_pib_destroy`, `_pib_run`, `_pib_exec`, `_pib_refresh`. The source code behind them is located under `source/pib_eval.c` and the exported function are declared in the final build command (see `Makefile`).
The builded PHP WASM version exposes these functions that will help you execute PHP: `_pib_init`, `_pib_destroy`, `_pib_run`, `_pib_exec`, `_pib_refresh`. The source code behind them is located under `source/pib_eval.c` and the exported function are declared in the final build command (see `Makefile`).

Thanks to [@seanmorris](https://github.com/seanmorris/php-wasm) you can also use persistent calls to keep things in memory by using:

Expand Down Expand Up @@ -90,14 +92,14 @@ More examples on the code usage are available on [@seanmorris's repository](http

## Preload data

You can build preloaded assets (`PRELOAD_ASSETS=/data`) using `make preload-data`. Then you'll need to add the `php-web.data.js` to the actual `php-web.js` file.
You can build preloaded assets (`PRELOAD_ASSETS=/data`) using `make preload-data`. Then you'll need to add the `php-web.data.js` to the actual `php-web.js` file.

This step on API Platform By Examples is done with the following Makefile using the original file as `php-web.ori.js`:

```make
UID=1000
API_PLATFORM_DIR=examples
DOCKER_RUN=docker run --rm -e ENVIRONMENT=web -v $(CURDIR):/src -v $(CURDIR)/../${API_PLATFORM_DIR}:/src/${API_PLATFORM_DIR} -w /src soyuka/php-emscripten-builder:latest
DOCKER_RUN=docker run --rm -e ENVIRONMENT=web -v $(CURDIR):/src -v $(CURDIR)/../${API_PLATFORM_DIR}:/src/${API_PLATFORM_DIR} -w /src soyuka/php-emscripten-builder:latest

preload:
${DOCKER_RUN} python3 /emsdk/upstream/emscripten/tools/file_packager.py ./public/php-web.data --preload "/src/${API_PLATFORM_DIR}" --js-output=./php-wasm/php-web.data.js
Expand Down

0 comments on commit a1f6061

Please sign in to comment.