Skip to content

[Demo] Run the demo application in the browser with PHP WebAssembly - #420

Merged
loic425 merged 4 commits into
Sylius:mainfrom
loic425:demo/php-wasm
Nov 25, 2026
Merged

loic425 merged 4 commits into
Sylius:mainfrom
loic425:demo/php-wasm

Conversation

@loic425

@loic425 loic425 commented Nov 25, 2026

Copy link
Copy Markdown
Member

Trying the Stack today means cloning the monorepo and running a database and a PHP server. Since #417 the test application runs on SQLite, so PHP compiled to WebAssembly (lyrixx/php-wasm-builder) can run it in a service worker: the demo becomes a static site on GitHub Pages, with no PHP server.

Live on my fork: https://loic425.github.io/SyliusStack/ (admin@example.com / admin)

  1. A demo anyone can open: wasm-demo/castor.php builds the application in prod without dev dependencies, with the fixtures in a SQLite database and ShadcnAdminUi with the rose theme (--ui and --theme change them). Data lives in the browser (IndexedDB) and is reset at each deploy.
  2. PHP has no network in the browser: it cannot fetch icons from Iconify nor serve files, so icons are imported at build time and assets and avatars are served by Pages, under its base path (/Stack/).
  3. A broken page must not be deployed: castor demo:check logs in and follows every link of the admin panel in PHP WebAssembly under node (61 pages). The workflow only deploys when it passes.
  4. The home page was empty: / now redirects to the dashboard, for the dev application too.

The login page also shows the test credentials, as on demo.sylius.com.

cd wasm-demo && castor demo:build && castor demo:serve

Before merging: a maintainer needs to set Settings › Pages › Source to "GitHub Actions". The demo is then deployed on each push to main at https://sylius.github.io/Stack/ (~10 min the first time, ~4 min with the cache).

BC: none, only the / route of the test application changes; the packages are untouched.

The test application runs on SQLite since Sylius#417: with lyrixx/php-wasm-builder,
PHP compiled to WebAssembly runs it in a service worker, so the demo can be
served by GitHub Pages, with no PHP server.

- wasm-demo/castor.php prepares the application (fixtures in a SQLite
  database, no dev dependencies, compiled assets and local icons) and builds
  PHP with it, with ShadcnAdminUi and the rose theme by default.
- wasm-demo/check.mjs logs in and checks every page of the admin panel in
  PHP WebAssembly, in node.
- The Demo workflow builds, checks and deploys it to GitHub Pages.
…rs under the base path

- The home page of the test application rendered an empty template: it now
  redirects to the dashboard, as anyone opening the demo expects.
- vich_uploader_asset() gives /avatars/speakers/..., without the base path
  of the demo: on GitHub Pages, it is under /<repository>/. The build gives
  the base path to the uri_prefix of the mapping.
- demo:check checks the redirection.
As on demo.sylius.com: an info alert, after the header of the login page,
with a hookable and its priority. Only with ShadcnAdminUi, whose components
it uses.
@loic425
loic425 merged commit 5f9d9c3 into Sylius:main Nov 25, 2026
36 checks passed
@loic425
loic425 deleted the demo/php-wasm branch November 25, 2026 09:32
loic425 added a commit that referenced this pull request Nov 25, 2026
The Demo workflow added in #420 builds and checks the demo on `main`,
then fails at the last step: `deploy-pages` reports "Found 0
artifact(s)" right after `upload-pages-artifact` uploaded `github-pages`
(see [this
run](https://github.com/Sylius/Stack/actions/runs/45588385862)). So
https://sylius.github.io/Stack/ is still not published.

The build exposes the runtime token of GitHub Actions to all its
following steps (`crazy-max/ghaction-github-runtime`, needed for the
buildx cache), and `deploy-pages` lists the artifacts with that token in
the same job.

→ The workflow is split into a `build` job and a `deploy` job (`needs:
build`) that only runs `deploy-pages`, as in GitHub's Pages starter
workflow, with a clean environment.

Tried on my fork: [both jobs
pass](https://github.com/loic425/SyliusStack/actions/runs/45589224361).
The fork already deployed with one job, though, so the proof for this
repository is the first run on `main` after the merge.

**BC**: none, only the Demo workflow changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant