Categories
Development

Moodle Dev Environment on Mac with MAMP

Moodle developers will know that the Moodle system requirements are quite high. When I came to set up my Moodle local development environment on my MacBook, it was nothing short of a nightmare.

Using the Moodle 4.3 server and database requirements as an example, I needed:

  • PHP 8+
  • MySQL 8+

The PHP version wasn’t an issue. MAMP has shipped with PHP 8 for as long as I remember (at least since 2021). But pre-July 2024, MAMP only came with MySQL 5.7.39. While the Moodle installation will be able to to run, it will not let you move past a requirements page. Luckily, there is a surprisingly simple and satisfying fix.

Introducing the environment.xml file

The long and rather tedious file lists every version of Moodle and it’s respective environment requirements. You’ll find it here:

admin/environment.xml

Now, I can’t speak for all database vendors and environment setups, but to get Moodle installed and functioning with a lower version of MySQL required just one change.

Changing Moodle’s system requirements

Here’s how you can change Moodle’s system requirement to allow your system setup to run Moodle.

  1. Open the admin/environment.xml file in your chosen editor.
  2. Scroll down to the Moodle version you are trying to install. The opening tag will start something like this <MOODLE version="4.3" ...>
  3. You should see a list of the database vendors.
  4. Change the version of your preferred vendor to whatever version you are able to run.

In my case, I changed the MySQL line in this block:

<DATABASE level="required">
   <VENDOR name="mariadb" version="10.6.7" />
   <VENDOR name="mysql" version="8.0" />
   <VENDOR name="postgres" version="13" />
   <VENDOR name="mssql" version="14.0" />
   <VENDOR name="oracle" version="19" />
</DATABASE>

To this:

<VENDOR name="mysql" version="5.7.39" />

Reload your Moodle installation page and you should be able to move forward in the installation process.

Final thoughts

As I mentioned above, MAMP now ships with MySQL 8 (since July 2024). So, this particular requirement shouldn’t be an issue for Mac users anymore. However, MAMP isn’t the only local server tool for Mac (you can run Moodle with XAMPP and Docker too). And with Moodle’s high requirements, it could easily outpace what these tools can offer in the future. Keep in mind the environment.xml file, and happy Moodling!