Skip to content

[Website] Add PHP next builds - #3692

Merged
adamziel merged 10 commits into
trunkfrom
adamziel/php-nightly-builds
May 28, 2026
Merged

adamziel merged 10 commits into
trunkfrom
adamziel/php-nightly-builds

Conversation

@adamziel

@adamziel adamziel commented May 27, 2026 •

Copy link
Copy Markdown
Collaborator

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

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:
    PHP_NEXT_MODES=jspi PHP_NEXT_APPEND=yes npm run recompile:php:web:next
  2. Started the website dev server:
    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:

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

@adamziel adamziel changed the title Add PHP nightly builds Add PHP master builds May 27, 2026
@adamziel adamziel changed the title Add PHP master builds Add PHP next builds May 27, 2026
@adamziel adamziel changed the title Add PHP next builds [Website] Add PHP next builds May 28, 2026
@adamziel
adamziel marked this pull request as ready for review May 28, 2026 00:11
@adamziel
adamziel requested review from a team and Copilot May 28, 2026 00:11
@adamziel
adamziel requested a review from brandonpayton May 28, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for PHP next (dev-branch) builds in the web Playground runtime by publishing large nightly artifacts to a separate branch and wiring website/runtime/UI/docs to consume them without committing binaries to trunk.

Changes:

  • Introduces next as a first-class PHP version across runtime APIs, blueprints schema/validator, and website UIs.
  • Adds tooling + CI to build and publish php-next web artifacts and to sync them into the gitignored website public directory for deploys/dev.
  • Adds/updates static pages and docs to expose and document ?php=next, including a PHP 8.6 preview page.

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/playground/website/vite.config.ts Avoids proxying php-next assets and adds a dev-only shim for importing the local client bundle.
packages/playground/website/src/components/site-manager/site-settings-form/unconnected-site-settings-form.tsx Adds next to the PHP version dropdown and avoids resetting when next is selected.
packages/playground/website/public/php-playground.html Adds next to the static PHP Playground UI, supports query params, and imports the client differently in dev.
packages/playground/website/public/php-code-snippet.js Dedents embedded PHP code before execution/display.
packages/playground/website/public/php-8-6.html Adds a new demo page showcasing PHP-next (8.6-dev) runnable snippets.
packages/playground/website/project.json Syncs php-next assets before dev server start and exposes a dedicated sync target.
packages/playground/website/demos/index.html Links to the new PHP 8.6 feature preview demo page.
packages/playground/website-extras/src/php-playground/url-state.ts Adds support for php/wp query params when no hash state exists.
packages/playground/website-extras/src/php-playground/store.ts Uses a curated PHP version list for the PHP Playground UI (including next).
packages/playground/website-extras/src/php-playground/php-versions.ts Defines PHP Playground version ordering and label mapping for next.
packages/playground/website-extras/src/php-playground/components/PlaygroundManager.tsx Passes preferredVersions.php into the Blueprint during boot.
packages/playground/website-extras/src/php-playground/components/Controls.tsx Displays a friendly label for next in the PHP version select.
packages/playground/client/src/index.ts Re-exports PHPNextVersion for consumers.
packages/playground/cli/src/run-cli.ts Filters next out of CLI --php choices.
packages/playground/blueprints/public/blueprint-schema.json Extends schema to accept php: "next" as an AllPHPVersion.
packages/playground/blueprints/public/blueprint-schema-validator.js Updates generated validator to accept next in AllPHPVersion.
packages/php-wasm/web/src/lib/load-runtime.ts Routes async-mode into loader selection and widens extension handling to AllPHPVersion.
packages/php-wasm/web/src/lib/get-php-next-module.ts Adds dynamic import logic for /php-next/index.js artifacts.
packages/php-wasm/web/src/lib/get-php-loader-module.ts Adds next handling and async-mode selection.
packages/php-wasm/web/src/lib/extensions/load-extensions.ts Explicitly disallows extensions for legacy + next builds.
packages/php-wasm/universal/src/lib/supported-php-versions.ts Introduces PHPNextVersion, type guard, and includes it in AllPHPVersions.
packages/php-wasm/universal/src/lib/index.ts Exports PHPNextVersion and isPHPNextVersion.
packages/php-wasm/node/src/lib/get-php-loader-module.ts Throws a clear error for next in the Node runtime.
packages/php-wasm/compile/sync-php-next-assets.mjs Adds a script to fetch the php-next-builds artifact branch into the gitignored public directory.
packages/php-wasm/compile/php/php8.6.patch Adds php-src patching needed for 8.6-dev builds.
packages/php-wasm/compile/php/Dockerfile Adds support for cloning php-src by ref and patch selection fallback for unknown minors.
packages/php-wasm/compile/build.js Adds PHP_REF plumbing to Docker builds for dev-branch builds.
packages/php-wasm/compile/build-php-next-web.mjs Adds a builder that compiles php-src default branch into php-next web artifacts + loader index/manifest.
packages/docs/site/docs/main/quick-start-guide.md Documents ?php=next usage in the quick start.
packages/docs/site/docs/developers/23-architecture/03-wasm-php-compiling.md Documents the php-next-builds workflow and local sync/build commands.
packages/docs/site/docs/developers/06-apis/query-api/01-index.md Documents next as a supported php Query API value (web-only).
packages/docs/site/docs/blueprints/03-data-format.md Documents Blueprint preferredVersions.php = "next" (web-only).
package.json Adds recompile:php:web:next and sync:php-next scripts.
AGENTS.md Documents the new next build and sync scripts.
.prettierignore Ignores generated php-next assets directory.
.github/workflows/refresh-php-next.yml Adds scheduled workflow to build + publish php-next-builds artifacts and trigger website deploy.
.github/workflows/deploy-website.yml Syncs php-next artifacts before building/deploying the website.
.eslintignore Ignores generated php-next assets directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamziel
adamziel merged commit 4f38ee9 into trunk May 28, 2026
53 checks passed
@adamziel

Copy link
Copy Markdown
Collaborator Author

Let's try it!

@adamziel
adamziel deleted the adamziel/php-nightly-builds branch May 28, 2026 10:04
mho22 added a commit that referenced this pull request Sep 30, 2026
## Motivation for the change, related issues

Every `@php-wasm/web` loader declares `dependencyFilename` with a bare
import of a `.wasm` file, which relies on the bundler treating it as an
asset. Vite 8 implements the WASM ESM Integration proposal and resolves
it as a module instead, so the build fails with `[MISSING_EXPORT]
"default" is not exported`. `assetsInclude` does not apply, so there is
no opt-out. This PR switches the web loaders to `new
URL('./php_X_Y.wasm', import.meta.url).href`, the form #3692 already
ships for the PHP next loaders.

## Implementation details

- **Loaders:** `Dockerfile` and `Dockerfile-5-2` emit the new line for
web builds; the Node branch keeps `path.join()`. The 16 committed
loaders get the same rewrite, so the published packages need no
recompile.
- **Breaking:** The loaders now use `import.meta`, so bundling
`@php-wasm/web` to `cjs` or `iife` throws `TypeError: Invalid URL` at
load. The published packages are unaffected — `index.cjs` keeps a native
dynamic `import()`. webpack 5 users must drop any `.wasm` `file-loader`
rule.
- **Vite configs:** The dead `wasm` entry goes from `viteIgnoreImports`
in six configs. `playground-website` and `playground-personal-wp` mark
`/^@php-wasm\/web-\d+-\d+$/` external, since neither calls
`loadWebRuntime()`.
- **Bundler tests:** Vite lib mode always inlines a `new URL()` asset as
base64, because `shouldInline()` returns early on `config.build.lib`.
Externalizing the version packages takes the web bundle from 617 MB to
817 KB.
- **Guards:** `loader-wasm-url.spec.ts` asserts all 16 loaders declare
`new URL()`; `run-bundler-tests` fails on a base64 WASM data URI. The
dead esbuild `loader` key goes too, leaving built artifacts
byte-identical.

## Testing Instructions (or ideally a Blueprint)

- [x] `npx nx test php-wasm-web` — 76 pass, 16 of them in
`loader-wasm-url.spec.ts`
- [x] Built a committed loader with Vite 8.3.1 — the bare import fails,
`new URL()` builds
- [x] Booted 8 PHP versions × jspi/asyncify on the dev server (16/16, no
console errors)
- [x] `playground-website` and `playground-personal-wp` build with 0
`.wasm` files, down from 16
- [ ] Confirm no consumer needs a `cjs` or `iife` bundle of the web
runtime

See: vitejs/vite#21779

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved WebAssembly loading across supported PHP versions by
resolving binaries relative to their modules.
* Updated web build configurations to keep PHP binaries from being
embedded as large base64 data.

* **Documentation**
* Updated bundler setup guidance with asset-serving requirements and
configuration notes.

* **Tests**
* Added checks for WebAssembly URL resolution and for unexpectedly
embedded binaries in web bundles.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants