Skip to main content

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.

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.

Requirements

ToolVersionNeeded for
Node.js18+Bundling the shell and PHP worker, running tests.
npmbundled with NodeDependency management.
Python 3anyMoodle build helpers and the docs site.
GitanyCloning the repo.
PHP8.3 with pdo_sqliteBuilding Moodle bundles (make bundle) and the native server (make up-local).
ComposeranyOnly 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

git clone https://github.com/ateeducacion/moodle-playground.git
cd moodle-playground
npm 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.
Build the worker, then the default Moodle branch (5.0) and its install snapshot:
make prepare
make bundle

Make commands reference

CommandWhat it doesUse it when
make prepareInstalls deps and builds the worker bundle only (no Moodle bundle).First setup, before make bundle.
make bundleBuilds one Moodle branch and its install snapshot (default: MOODLE_500_STABLE).You need a runnable Moodle. Override the branch with BRANCH=....
make prepare-allWorker + all Moodle branches.Reproducing CI, or hosting every Moodle version locally.
npm run build-workerRebuilds dist/php-worker.bundle.js only.After editing anything in src/runtime/** or src/blueprint/**.
Rebuild the worker after editing blueprint or runtime code. The blueprint engine and all step handlers are bundled into the worker at build time. After changing files under src/blueprint/** or src/runtime/**, run npm run build-worker — otherwise the running app keeps using the stale bundle. Unit tests run the source directly, so they will not catch a missing rebuild.

Run the dev server

make serve
Open http://localhost:8080. The default admin login is 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.
Override the port with PORT:
PORT=9000 make serve

Build everything and serve in one step

make up runs a full build of all Moodle branches and then starts the dev server:
make up
This is the slowest option — it builds every branch (needing Composer for 5.1+). Use it when you want every Moodle version available from a single local instance. For day-to-day work, 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.
make up-local
It builds the selected branch first, then serves it. State is isolated per branch under .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:
# Run the development branch
BRANCH=main make up-local

# Pick a port and a specific PHP binary
BRANCH=MOODLE_500_STABLE LOCAL_PORT=8082 LOCAL_PHP=php83 make up-local
VariableDefaultMeaning
BRANCHMOODLE_500_STABLEWhich Moodle branch to serve.
LOCAL_PORT8081Port for the native php -S server.
LOCAL_PHPphp84PHP 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=MOODLE_404_STABLE make bundle
BRANCH=main make bundle
BRANCH valueMoodle version
MOODLE_404_STABLE4.4
MOODLE_405_STABLE4.5
MOODLE_500_STABLE5.0 (default)
MOODLE_501_STABLE5.1
MOODLE_502_STABLE5.2
maindevelopment
At runtime you can switch versions without rebuilding by using the moodle and php URL parameters — for example ?moodle=4.4. See the URL Parameters page for the full reference.

Generated assets

1

assets/moodle/

Prebuilt Moodle ZIP bundles, one per branch. Loaded into MEMFS at boot. Produced by make bundle.
2

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.
3

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.
4

dist/

The compiled PHP worker bundle (dist/php-worker.bundle.js). Produced by npm run build-worker. Bundled with esbuild and loaded by remote.html at runtime.

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.

Build docs developers (and LLMs) love