Installing Moodle with Composer: what it changes for your deployment
A platform team that must install Moodle the same way in staging and production, inside infrastructure it controls, needs a repeatable build rather than a hand-assembled server. Moodle 5.2 provides third-party libraries via Composer and supports installation with Composer, so the dependency tree of a given release can be pinned, reviewed and reproduced. The first decision is whether your build pipeline will treat Composer as the source of truth for libraries and plugin dependencies, or only as a convenience during a manual install. That choice determines what your CI pipeline must produce and what your change records must show.
Composer handles the PHP libraries Moodle depends on, the install steps that fetch them, and the plugin dependencies you declare in your project. It does not replace the rest of the stack. Your web server, PHP runtime and extensions, database, moodledata directory, and cron schedule remain your responsibility, and none of them is versioned by Composer. Confirm in the Moodle 5.2 release notes exactly which libraries and install paths are covered before you write your lockfile policy, because the boundary between core code and vendored libraries is the detail most likely to surprise an auditor reviewing your change history.
Two related constraints belong in the same plan. From Moodle 5.1, the web server document root must point to the public directory rather than the main Moodle folder, or the site may show directory listings or errors, so your Composer-built artifact and your web server configuration must agree on the path. Moodle 5.2 has security support until 4 October 2027, which gives you a fixed window to schedule the next upgrade through the same pipeline. Ask your partner or internal team to confirm how the lockfile, the public path and the upgrade calendar will be promoted together from staging to production.
Which Composer-based approach fits which team
This table compares three ways to build a Moodle site that uses Composer: a released tarball with bundled dependencies, a Git-based build that runs Composer in CI, and a container image built from locked dependencies. Read each row against your team's skills and change rate, then confirm the exact commands and file layout with the method you choose.
| Approach | When it fits | Who maintains the build | Upgrade path |
|---|---|---|---|
| Released tarball with bundled dependencies | Small teams with one or two environments and infrequent plugin changes | Usually the site administrator, with the vendor's release package as the base | Replace the package and run the standard upgrade steps; confirm how your plugins are re-applied |
| Git-based build with Composer run in CI | Teams that track configuration and custom code in Git and deploy to several environments | A platform or DevOps engineer who owns the pipeline and lock files | Change the core version in the repository, rebuild in CI, promote through staging; confirm how lock files are updated |
| Container image built from locked dependencies | Organizations already running containers, or needing identical artifacts across staging and production | A platform team that owns the Dockerfile, base image patching and registry | Build a new image per release and roll it out; confirm database upgrade steps run as a separate job |
| Dependency scanning and approval step | Regulated environments that must review each third-party library before use | Security or compliance reviewers with the build team | Re-scan on every version change; confirm which tool and policy your assessors accept |
| Air-gapped or restricted network builds | Sites that cannot reach public package registries during the build | The team that operates the internal mirror or artifact store | Mirror new packages before each upgrade; confirm the mirror covers every locked dependency |
| Plugin management as dependencies | Organizations with many third-party plugins that need pinned versions | The team responsible for plugin review and testing | Update pinned versions in the lock file and retest each plugin; confirm compatibility with the target core release |
Setting up a reproducible Moodle build with Composer
This sequence turns a Moodle codebase into a versioned artifact that is built once in CI, checked against its dependency lock file, and deployed unchanged to staging and production. The result is an install where every environment runs the same code and the same third-party libraries.
Confirm the target release and its minimums
The platform team picks the target Moodle release and checks its PHP, database and upgrade-path requirements before any code is touched. For Moodle 5.2, the Composer support comes from the release notes, and the server minimums for that release must be confirmed on the release notes page for the version you choose. Record the target PHP version, the database engine and its version, and the earliest Moodle version your existing site can upgrade from. Done means a short written compatibility record is signed off by the application owner and the infrastructure lead, and the CI runner image is set to a matching PHP version.
Commit the Composer manifest and lock file
The developer or DeployOpen engineer creates the composer.json manifest for the Moodle codebase, including the core version constraint, any third-party libraries and any plugins managed as dependencies, then runs the install locally to generate composer.lock. Both files go into version control together, and the lock file is never regenerated silently in later builds. Done means a clean checkout of the repository can run the install and produce the same vendor tree on a second machine.
Run the install in CI
A CI pipeline runs Composer with the locked dependencies on a clean runner that matches the target PHP version, then runs the Moodle code checks your team has agreed on. Dependency installs should use the lock file exactly as committed, so the pipeline fails rather than updating a package without a review. Done means the pipeline completes on every commit to the release branch and the job log records the Composer and PHP versions used.
Produce a versioned build artifact
The pipeline packages the built Moodle tree, including the vendor directory, into a single versioned artifact such as an archive or a container image, and tags it with the Git commit and the Moodle release. Compiled or generated files are included only if the build created them, and the moodledata directory is never part of the artifact. Done means the artifact has a published checksum and is stored in a registry or artifact repository that staging and production can reach.
Verify lock file hashes across environments
Before deployment, the release engineer compares the checksum of composer.lock and the artifact checksum recorded in the pipeline with the values that the staging and production hosts report after they unpack the artifact. A mismatch stops the release. The same check should confirm that the web server document root points to the /public directory, since Moodle 5.1 and later serve from that folder and otherwise may show directory listings or errors. Done means both environments report identical hashes and a passing document root check.
Deploy the same artifact to staging and production
The operations team deploys the exact artifact that passed staging tests to production, without rebuilding it. Configuration values such as database credentials and the dataroot path are supplied through the host environment, not baked into the artifact. Done means the production host runs the tagged artifact, and the deployment record links the production change to the staging test run that approved it.
Run the Moodle upgrade and post-install checks
After the new code is in place, an administrator runs the Moodle upgrade from the command line or the site administration screen, then completes the post-install checks for PHP extensions, cron, caching and the security report. Upgrade steps are logged, and the team keeps a copy of the database and dataroot taken before the upgrade started. Done means the upgrade finishes without errors, the site administration notifications page shows no blocking issues, and a scheduled cron run completes successfully.
How the build moves from source to production
The build starts in the source repository, where composer.json and composer.lock pin Moodle core, third-party libraries and plugins. A CI job installs from the lock file and packages a versioned artifact, which is promoted to staging and then production. The database, dataroot and config.php live outside the artifact in their own stores, so each release is the same code pointed at different data. Check that the lock file is committed and that the artifact is never edited on the server.
Composer lock file drives a versioned artifact, with data stores kept outside it.
Security and supply chain considerations for Composer builds
A Composer-built Moodle inherits the trust of every package it pulls in, from core libraries to third-party plugins. The cards below cover the controls that keep the build reproducible, the people and secrets around it protected, and the patch cycle current with Moodle's releases.
Pin dependencies and review lock file changes
Commit composer.lock and treat every change to it as a code change that needs review. A lock file change can move a library several versions at once, so the diff should show which packages changed, from what version to what version, and why. Confirm that production installs use composer install against the committed lock file rather than resolving fresh versions at deploy time. Ask whether your CI fails when the lock file and composer.json disagree.
Restrict who can publish artifacts
Decide which pipeline and which people can build and push the image or archive that reaches production. Limit write access to the package registry, artifact store and container registry, and require protected branches for the build source. Confirm that staging and production pull the same tagged artifact, so that what was tested is what gets deployed. Record who approved each release.
Keep secrets out of the repository and logs
Database passwords, SMTP credentials, API keys for AI or video providers and the config.php database settings must never be committed to the repository or printed by build steps. Inject them at runtime from a secrets manager or the platform's secret store. Mask secret variables in CI logs and check that composer output, debug flags and failed-build dumps do not echo environment values.
Vet third-party plugins before adding them
A plugin added as a Composer dependency runs code inside your Moodle with the privileges of the web server. Before adding one, review its source, maintainer history, license, the declared dependencies it brings in, and whether it has a security advisory history. Check that it supports your target Moodle version and PHP version. Record the decision and the reviewer so that future updates go through the same review.
Scan dependencies in the build pipeline
Run a dependency vulnerability scan on every build, covering both core libraries and plugin packages, and fail the build on findings above a threshold you define. Scanning finds known issues in the lock file, but it does not review code that is new to your project, so keep the vetting step as well. Ask your scanner vendor which advisory sources it uses for PHP packages.
Patch on a cadence tied to Moodle releases
Moodle ships minor point releases every two months, and security fixes arrive through them. Schedule dependency updates to follow those releases so that core, libraries and plugins move together and are tested as one set. Moodle 4.5 has security support until 4 October 2027, and Moodle 5.2 until 4 October 2027, so set a retirement date for each branch you run. Keep a rollback artifact for every release.
Moodle release datesQuestions teams ask before installing Moodle with Composer
Does Composer support in Moodle 5.2 mean I can drop the manual install entirely?
Not entirely. Moodle 5.2 provides third-party libraries through Composer and supports installation with it, so the dependency and install steps become scriptable. You still choose a release, a database, a web server layout and a dataroot location, and you still run the upgrade and post-install checks. Confirm the exact install commands and the supported Composer workflow in the Moodle 5.2 release notes and in your own staging environment before you commit to a pipeline design.
What drives the cost of a Composer-based Moodle build?
The main drivers are the size of the plugin set, the number of environments that must match (typically development, staging and production), the maturity of your CI pipeline, and how many third-party plugins need security and licence vetting. Each plugin adds version pinning, compatibility testing and upgrade work over its life. Ask any provider to price these components separately: initial pipeline design, plugin vetting, environment setup and recurring upgrade testing. Whether the work is one-time or recurring depends on how often you move to new Moodle releases.
How long does it take to reach a first working Composer build?
The duration depends on how many plugins you start with, whether your target server details are settled, and whether a CI runner and repository already exist. A small, core-only build against a known server is far quicker than a build with a long plugin list that needs vetting. Ask for a timeline tied to a written scope, with milestones for the first clean install, the first successful staging deployment and the first upgrade rehearsal. Moodle's supported database and PHP minimums for your target release will affect this timeline, so confirm them early.
What does my team need to supply before work starts?
Expect to supply a Git repository your team controls, a CI runner with network access to the package sources you approve, and the details of your target servers: operating system, web server, PHP version, database engine and version, storage layout and outbound network rules. You also need a list of the plugins you want, with owners who can approve them. If you run air-gapped or restricted networks, say so at the start, because package sources and update checks change the design. Confirm each item in writing as part of the scope.
Can an internal team build and maintain this without outside help?
Yes, if the team already runs Linux servers, PHP applications and CI pipelines, and has someone who can own Moodle upgrades. The hard parts are less the first install and more the ongoing discipline: pinning plugin versions, testing each Moodle minor release, and keeping staging and production identical. A partner can design the pipeline, vet plugins and hand over a documented process, or support it on a retainer. Compare the cost of training and staffing against a fixed-scope engagement, using a quote built from your written requirements.
Which Moodle versions and database minimums should I plan around?
Plan around the release you intend to run for its full support window, not only the one that is current. Moodle 5.1 requires 64-bit PHP 8.2 or later and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later. Moodle 5.3 raises the minimums to PHP 8.3 or later and PostgreSQL 17, MariaDB 11.4 or SQL Server 2019 or later, and sites must run Moodle 4.4 or later to upgrade. Your pipeline's PHP and database images should match these minimums, so confirm the requirements for your chosen release in the Moodle 5.3 release notes.
What breaks most often in Composer-managed Moodle builds?
The most common failures are plugin version conflicts with a new core release, a document root that still points at the main Moodle folder instead of /public from Moodle 5.1 onward, and a PHP extension present on the build runner but missing on the server. Dependency updates can also change libraries that plugins rely on. Guard against these with pinned versions, a staging run for every change, and automated checks on the web server configuration. Ask any partner how they test a release candidate before it reaches production.
What Composer does not manage for you
Composer manages PHP packages, including the third-party libraries Moodle 5.2 now provides through Composer and the plugins you declare as dependencies. It does not provision the database server, configure your web server, create the dataroot, schedule cron, take backups or write the values in config.php. Those remain your responsibility after a Composer install, and a clean composer install tells you nothing about whether any of them are correct. Confirm the database engine and version against the minimums in the release notes for the Moodle version you are deploying before you touch the schema.
The web server and file layout need separate decisions. From Moodle 5.1 the document root must point to the /public directory, and a Composer-built tree does not change that requirement. Keep the dataroot outside the web root, set its ownership for the PHP-FPM user, and confirm that cron runs as a scheduled process rather than relying on page traffic. Backups of both the database and the dataroot also sit outside Composer's scope, so set and test a restore procedure independently of the build artifact. The Moodle 5.2 release notes cover the Composer change itself, but not these operational settings.
Composer also does not perform the Moodle upgrade. Moving between major releases still runs the database upgrade from the Moodle admin interface or CLI, and each release sets its own minimum starting version and server requirements. Plan that step as a separate change with its own test run on staging. For the server pieces, use the sibling pages in this hub: the Ubuntu with Nginx and PHP-FPM guide for web server and PHP settings, the Docker page for a containerized runtime with cron as its own process, and the dataroot planning page for file storage. Each one should be checked against your own environment before go-live.
How DeployOpen scopes and delivers a Composer-based Moodle build
DeployOpen plans, builds, documents and supports self-hosted Moodle inside your own infrastructure, including the Composer-based build pipeline described on this page. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- Inventory the Moodle version, plugins and third-party libraries you need before choosing a Composer layout.
- Confirm the PHP, database and web server targets for your Moodle release in the written scope.
- Agree which plugins are managed as Composer dependencies and which are vetted and copied in manually.
How we build
- Create a Composer project that pins Moodle core, libraries and approved plugins to explicit versions.
- Configure the web server document root and dataroot so the build works with your chosen hosting model.
- Set up a CI pipeline that builds, lints and tests the same artifact promoted from staging to production.
How we hand over
- Deliver the repository, lock files, build scripts and CI configuration with documented steps for your team.
- Provide an upgrade runbook covering how Composer updates are reviewed, tested and promoted to production.
- Walk your engineers through rollback, dependency pinning and the checks run after each deployment.
How we support
- Offer ongoing support, upgrades and continuous testing for the build pipeline as a retainer.
- Review dependency updates and Moodle point releases against your pinned plugin set on a scheduled basis.
- Keep documentation current as your plugin list, hosting targets and CI tooling change over time.

