Skip to content

Commit 4f38ee9

Browse files
authored
[Website] Add PHP next builds (#3692)
## What it does Adds PHP `next` builds for the Playground **web** runtime without committing the binaries to `trunk`. - Publishes generated web binaries to a separate `php-next-builds` branch. - Syncs gitignored `packages/playground/website/public/php-next/` assets for website deploys and local dev. - Supports `php=next` in the Query API and Blueprint `preferredVersions.php`. - Adds a PHP 8.6 preview page with runnable examples: `php-8-6.html`. - Adds PHP Playground support for `?php=next` directly, displayed as `Next (development)`. - Documents the runtime, asset flow, and API usage. Demo: https://playground.wordpress.net/php-8-6.html PHP Playground: https://playground.wordpress.net/php-playground.html?php=next ## Rationale `next` is release-cycle neutral. It can point at PHP `8.6.0-dev` today and PHP `8.7.0-dev` later without teaching Playground about each upcoming version in UI code. The binaries are large and change nightly. Publishing them to `php-next-builds` keeps daily binary churn out of `trunk` while still making the artifacts available to `playground.wordpress.net` and local dev servers. This PR intentionally ships **web main modules only**. PHP extensions are disabled for `next` until we also publish matching ABI side modules. ## Implementation ```text php-src default development branch -> refresh-php-next.yml -> npm run recompile:php:web:next -> packages/playground/website/public/php-next/ (gitignored) -> php-next-builds branch (binary artifact branch) -> deploy-website.yml / local dev sync -> ?php=next / Blueprint preferredVersions.php="next" ``` Key pieces: 1. `@php-wasm/universal` defines `PHPNextVersion = "next"` and includes it in `AllPHPVersion`. 2. `@php-wasm/web` detects `version === "next"` and dynamically imports `/php-next/index.js`. 3. `build-php-next-web.mjs` compiles php-src's default development branch and writes the `index.js` loader plus `jspi` / `asyncify` artifacts. 4. `sync-php-next-assets.mjs` fetches `php-next-builds` into the gitignored website public directory. 5. `deploy-website.yml` syncs those assets before deploying `playground.wordpress.net`; `npm run dev` syncs them for local website dev. 6. PHP Playground accepts `?php=next`, shows `Next (development)`, and passes `next` to the runtime. There is no `8.6` mapping to update next cycle. 7. Static Playground pages use a dev-server shim for `/website-server/client/index.js`, so local `php-playground.html` imports the local client instead of the deployed one. CLI support is a follow-up PR. The next PR can reuse `php-next-builds`, add Node.js `next` artifacts, and teach Playground CLI how to resolve `--php=next`. Until then, the CLI filters `next` out of `--php` choices and the Node runtime returns an explicit “web runtime only” error if called directly. ## Testing instructions Manual verification performed: 1. Built a local `next` artifact: ```bash PHP_NEXT_MODES=jspi PHP_NEXT_APPEND=yes npm run recompile:php:web:next ``` 2. Started the website dev server: ```bash npm run dev ``` 3. Opened `http://127.0.0.1:5400/website-server/?php=next&wp=latest` and confirmed WordPress booted with PHP `8.6.0-dev`. 4. Confirmed the browser loaded the gitignored local assets: - `/website-server/php-next/index.js` - `/website-server/php-next/jspi/php_8_6.js` - `/website-server/php-next/jspi/8_6_0-dev/php_8_6.wasm` 5. Opened `http://127.0.0.1:5400/website-server/php-playground.html?php=next` and confirmed: - PHP select shows `Next (development)`. - The example renders `Hello from PHP 8.6.0-dev`. Checks run: ```bash node --check packages/php-wasm/compile/build-php-next-web.mjs node --check packages/php-wasm/compile/sync-php-next-assets.mjs npx nx build playground-blueprints --output-style=stream npx nx typecheck php-wasm-universal --output-style=stream npx nx typecheck php-wasm-web --output-style=stream npx nx typecheck playground-client --output-style=stream npx nx typecheck playground-website-extras --output-style=stream npx nx typecheck playground-website --output-style=stream npx nx build playground-website --output-style=stream npm run format:uncommitted git diff --check ```
1 parent 32db600 commit 4f38ee9

39 files changed

Lines changed: 1273 additions & 126 deletions

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ packages/php-wasm/node/src/test/__test*
1414
.nx
1515
playwright-report
1616
rollup.d.ts
17+
packages/playground/website/public/php-next

.github/workflows/deploy-website.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ jobs:
7676
# Allow deploying a specific ref for folks who want to pin a specific version.
7777
ref: ${{ vars.GIT_REF_TO_DEPLOY }}
7878
- uses: ./.github/actions/prepare-playground
79+
- name: Sync PHP next build assets
80+
run: npm run sync:php-next
7981
- run: npx nx build playground-website
8082
env:
8183
CORS_PROXY_URL: ${{ vars.CORS_PROXY_URL }}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: 'Refresh PHP Next'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
php_ref:
7+
description: 'php-src ref to build (defaults to php-src development branch)'
8+
required: false
9+
# Refresh PHP next binaries every day at 6am UTC.
10+
schedule:
11+
- cron: '0 6 * * *'
12+
13+
concurrency:
14+
group: refresh-php-next
15+
16+
# Disable permissions for all available scopes by default.
17+
# Any needed permissions should be configured at the job level.
18+
permissions: {}
19+
20+
jobs:
21+
build_publish_and_deploy:
22+
# Only run this workflow on the playground repo, from the trunk branch,
23+
# and when triggered by a Playground maintainer.
24+
if: >
25+
github.repository == 'WordPress/wordpress-playground' &&
26+
github.ref == 'refs/heads/trunk' && (
27+
github.actor == 'adamziel' ||
28+
github.actor == 'dmsnell' ||
29+
github.actor == 'bgrgicak' ||
30+
github.actor == 'brandonpayton' ||
31+
github.actor == 'zaerl' ||
32+
github.actor == 'janjakes' ||
33+
github.actor == 'mho22' ||
34+
github.actor == 'ashfame'
35+
)
36+
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 240
39+
permissions:
40+
contents: write # Required to push the refreshed PHP next branch.
41+
actions: write # Required to trigger the deploy-website workflow.
42+
environment:
43+
name: wordpress-assets
44+
steps:
45+
- uses: actions/checkout@v5
46+
with:
47+
ref: trunk
48+
clean: true
49+
persist-credentials: true
50+
ssh-key: ${{ secrets.DEPLOY_KEY }}
51+
submodules: true
52+
- uses: ./.github/actions/prepare-playground
53+
with:
54+
# The build uses JSPI which is supported in Node.js 23+.
55+
# Let's pick 24 as an LTS release.
56+
node-version: 24
57+
- name: Build PHP next binaries
58+
shell: bash
59+
env:
60+
PHP_NEXT_REF: ${{ github.event.inputs.php_ref }}
61+
run: npm run recompile:php:web:next
62+
- name: Publish PHP next binaries branch
63+
shell: bash
64+
run: |
65+
set -euo pipefail
66+
branch="php-next-builds"
67+
publish_dir="$(mktemp -d)"
68+
trap 'rm -rf "$publish_dir"' EXIT
69+
cp -a packages/playground/website/public/php-next/. "$publish_dir/"
70+
71+
git switch --orphan php-next-publish
72+
git rm -rf . || true
73+
git clean -fdx
74+
cp -a "$publish_dir/." .
75+
git add -A
76+
git config --global user.name "deployment_bot"
77+
git config --global user.email "deployment_bot@users.noreply.github.com"
78+
git commit -m "Refresh PHP next builds"
79+
git push --force origin HEAD:"$branch"
80+
- name: Deploy website
81+
uses: benc-uk/workflow-dispatch@v1
82+
with:
83+
workflow: deploy-website.yml
84+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ vite.config.ts.timestamp-*.mjs
6262
Thumbs.db
6363

6464
# Playground artifacts
65+
packages/playground/website/public/php-next/
6566
php.js.bak
6667
**/test-results/
6768
**/playwright-report/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ __pycache__
1515
.nx
1616
.vscode
1717
rollup.d.ts
18+
/packages/playground/website/public/php-next

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ npm run format:uncommitted # Format only uncommitted files
5555
# PHP Recompilation (see compile-php-wasm skill for details)
5656
npm run recompile:php:web # Recompile all PHP versions for web
5757
npm run recompile:php:node # Recompile all PHP versions for Node.js
58+
npm run recompile:php:web:next # Recompile PHP next web binaries
59+
npm run sync:php-next # Fetch gitignored PHP next assets for local dev
5860

5961
# WordPress Builds
6062
npm run rebuild:wordpress-builds # Rebuild all WordPress versions

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
"recompile:php:node:asyncify:8.0": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=8.0 ",
6969
"recompile:php:node:asyncify:7.4": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=7.4 ",
7070
"recompile:php:node:asyncify:7.3": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=7.3 ",
71-
"recompile:php:node:asyncify:7.2": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=7.2 "
71+
"recompile:php:node:asyncify:7.2": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=7.2 ",
72+
"recompile:php:web:next": "node packages/php-wasm/compile/build-php-next-web.mjs",
73+
"sync:php-next": "node packages/php-wasm/compile/sync-php-next-assets.mjs"
7274
},
7375
"private": true,
7476
"dependencies": {

packages/docs/site/docs/blueprints/03-data-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The `landingPage` property tells Playground which URL to navigate to after the B
5555

5656
The `preferredVersions` property declares your preferred PHP and WordPress versions. It can contain the following properties:
5757

58-
- `php` (string): Loads the specified PHP version. Accepts `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`, or `latest`. Minor versions like `7.4.1` are not supported.
58+
- `php` (string): Loads the specified PHP version. Accepts `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`, `latest`, or `next`. Minor versions like `7.4.1` are not supported. Use `next` to preview the next PHP version from the php-src development branch; it is currently supported by the web runtime only.
5959
- `wp` (string): Loads the specified WordPress version. Accepts the last seven major WordPress versions. As of April 28, 2026, that's `6.3`, `6.4`, `6.5`, `6.6`, `6.7`, `6.8`, or `6.9`. You can also use the generic values `latest`, `beta`, or `nightly` (alias `trunk`). `beta` resolves to the most recent Beta or Release Candidate of an active release cycle; `nightly`/`trunk` builds straight from the WordPress development branch.
6060

6161
```js

packages/docs/site/docs/developers/06-apis/query-api/01-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ You can go ahead and try it out. The Playground will automatically install the t
2424

2525
| Option | Default Value | Description |
2626
| ------------------ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27-
| `php` | `8.5` | Loads the specified PHP version. Accepts `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5` or `latest`. |
27+
| `php` | `8.5` | Loads the specified PHP version. Accepts `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`, `latest`, or `next`. Use `next` to preview the next PHP version from the php-src development branch; it is currently supported by the web runtime only. |
2828
| `php-extension` | | Loads a custom PHP.wasm extension manifest before PHP starts. Accepts absolute, root-relative, or page-relative HTTP(S) URLs. Can be used multiple times. |
2929
| `wp` | `latest` | Loads the specified WordPress version. Accepts the last three major WordPress versions. As of June 1, 2024, that's `6.3`, `6.4`, or `6.5`. You can also use the generic values `latest`, `nightly`, or `beta`. |
3030
| `blueprint-url` | | The URL of the Blueprint that will be used to configure this Playground instance. |

packages/docs/site/docs/developers/23-architecture/03-wasm-php-compiling.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ To find out more about each step, refer directly to the [Dockerfile](https://git
2222

2323
To build all PHP versions, run `nx recompile-php:all php-wasm-web` (or `php-wasm-node`) in the repository root. You'll find the output files in `packages/php-wasm/php-web/public`. To build a specific version, run `nx recompile-php:all php-wasm-node --PHP_VERSION=8.0 --WITH_JSPI=yes` (and repeat with `--WITH_JSPI=no`).
2424

25+
### PHP next builds
26+
27+
Playground can also run the next PHP version from the php-src development branch in the web runtime. These builds are published separately from the main repository because the generated WebAssembly files are large and change often.
28+
29+
The nightly refresh workflow builds the php-src development branch, writes the web artifacts to the gitignored `packages/playground/website/public/php-next/` directory, and publishes the result to the `php-next-builds` branch. Website deploys and the local dev server sync that branch before serving `?php=next`.
30+
31+
To refresh the local copy manually, run:
32+
33+
```sh
34+
npm run sync:php-next
35+
```
36+
37+
To rebuild the web artifacts locally from the php-src development branch, run:
38+
39+
```sh
40+
npm run recompile:php:web:next
41+
```
42+
43+
`php=next` currently ships web main modules only. Matching extension side modules and Playground CLI support are separate follow-up work.
44+
2545
### PHP extensions
2646

2747
PHP is built with several extensions listed in the [`Dockerfile`](https://github.com/WordPress/wordpress-playground/blob/trunk/src/packages/php-wasm/compile/Dockerfile).

0 commit comments

Comments
 (0)