Run Moodle Playground on your own machine — to host it yourself, work offline, or hack on the code. If you only want to try the playground, use the hosted app at moodle-playground.com instead; nothing on this page is needed for that.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ateeducacion/moodle-playground/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
| Tool | Version | Needed for |
|---|---|---|
| Node.js | 18+ | Bundling the shell and PHP worker, running tests. |
| npm | bundled with Node | Dependency management. |
| Python 3 | any | Moodle build helpers and the docs site. |
| Git | any | Cloning the repo. |
| PHP | 8.3 with pdo_sqlite | Building Moodle bundles (make bundle) and the native server (make up-local). |
| Composer | any | Only when building Moodle 5.1+ bundles (MOODLE_501_STABLE, MOODLE_502_STABLE, main). |
PHP 8.3 is only needed at build time — it generates the SQLite install snapshot that makes cold-start fast. The playground itself runs PHP compiled to WebAssembly in the browser, so end users need nothing installed.
Clone and install
Build the runtime
A working instance needs two artifacts: the PHP worker bundle (dist/) and at least one Moodle bundle (assets/moodle/). Use the targets below to build them.
- First build
- All branches
- Worker only
Build the worker, then the default Moodle branch (5.0) and its install snapshot:
Make commands reference
| Command | What it does | Use it when |
|---|---|---|
make prepare | Installs deps and builds the worker bundle only (no Moodle bundle). | First setup, before make bundle. |
make bundle | Builds one Moodle branch and its install snapshot (default: MOODLE_500_STABLE). | You need a runnable Moodle. Override the branch with BRANCH=.... |
make prepare-all | Worker + all Moodle branches. | Reproducing CI, or hosting every Moodle version locally. |
npm run build-worker | Rebuilds dist/php-worker.bundle.js only. | After editing anything in src/runtime/** or src/blueprint/**. |
Run the dev server
admin / password (override it with an installMoodle step in a blueprint).
The playground uses a service worker to route requests to the in-browser PHP runtime. Service workers only register on
https:// or http://localhost, so opening index.html directly from the filesystem (file://) will not work. Always serve through make serve.PORT:
Build everything and serve in one step
make up runs a full build of all Moodle branches and then starts the dev server:
make prepare && make bundle && make serve is faster.
Native PHP server (without WASM)
make up-local runs Moodle on a native php -S server using the same patched source the WASM runtime uses, backed by a native SQLite database. This is useful for debugging Moodle behavior without the WebAssembly layer — for example, to verify whether a bug is in the WASM routing or in the SQLite driver itself.
.cache/local/<branch>/, so switching branches does not reuse the same database or moodledata. The PHP binary you point it at must have pdo_sqlite enabled.
Override the branch, port, or PHP binary:
| Variable | Default | Meaning |
|---|---|---|
BRANCH | MOODLE_500_STABLE | Which Moodle branch to serve. |
LOCAL_PORT | 8081 | Port for the native php -S server. |
LOCAL_PHP | php84 | PHP binary to launch (must have pdo_sqlite). |
Selecting Moodle versions
The build defaults to Moodle 5.0 (MOODLE_500_STABLE). Override it with BRANCH=... on make bundle or make up-local:
BRANCH value | Moodle version |
|---|---|
MOODLE_404_STABLE | 4.4 |
MOODLE_405_STABLE | 4.5 |
MOODLE_500_STABLE | 5.0 (default) |
MOODLE_501_STABLE | 5.1 |
MOODLE_502_STABLE | 5.2 |
main | development |
moodle and php URL parameters — for example ?moodle=4.4. See the URL Parameters page for the full reference.
Generated assets
assets/moodle/
Prebuilt Moodle ZIP bundles, one per branch. Loaded into MEMFS at boot. Produced by
make bundle.assets/moodle/snapshot/
Pre-built install snapshots (SQLite databases after a fresh Moodle install). These snapshots make cold-start roughly 3 seconds instead of running a full CLI install every time.
assets/manifests/
Per-branch JSON manifests listing available bundle files (
MOODLE_*.json, main.json, latest.json). Used by the shell to build the version selector.Next steps
Basic usage
Drive the running playground: navigate pages, run blueprints, switch versions.
Blueprints
Provision courses, users, and plugins at boot using blueprint JSON files.
Architecture
How the shell, service worker, and PHP runtime fit together.
Troubleshooting
Debug runtime errors, SQLite driver bugs, and networking issues.