A dockerized Moodle 3.2 development environment with containers:
- nginx
- PostgreSQL
- PHP-FPM 5.6
- Mailcatcher
- Selenium (for Behat)
- Built-in web server (for Behat)
- Docker 17.03.0 (CE)
- Docker Compose 1.11.2
docker-compose build
docker-compose up -d
Run the bash initialization script:
. utils/init.sh
The above bash initialization script should work on Windows environments that have bash ("Docker Quickstart Terminal" for "Docker Toolbox") however it won't work in PowerShell (obviously) if using (the newer) "Docker for Windows" (instead of the older "Docker Toolbox"). If using "Docker for Windows", the individual commands in utils/init.sh
should be performed manually.
In some Windows environments ("Docker Quickstart Terminal" for "Docker Toolbox") commands that specify a working directory (e.g. -w /var/www/html/moodle
) may need an initial double slash (e.g. -w //var/www/html/moodle
).
docker-compose exec php bash
php -a
docker-compose exec pgsql bash
psql -Upostgres
docker-compose logs -f
docker-compose run --rm -w /var/www/html/vendor/moodle/moodle php php admin/cli/cron.php
docker-compose run --rm -w /var/www/html/vendor/moodle/moodle php vendor/bin/phpunit --colors=always --testsuite local_todolist_testsuite
docker-compose run --rm -w /var/www/html/vendor/moodle/moodle php vendor/bin/behat -c ../../../moodledata/behat/behatrun/behat/behat.yml path/to/feature
. utils/behat.sh
docker-compose run --rm -w /var/www/html/vendor/moodle/moodle php php admin/cli/purge_caches.php
docker-compose run --rm php php utils/plugin_types.php
docker-compose exec php bash
cd /path/to/moodle/plugin
phpcs version.php
Remote debugging with XDebug is possible in PHPStorm and Visual Studio Code.
Debugging in VSCode requires the PHP Debug extension.
To set up source code mapping, add the lines below to the "Listen for XDebug" configuration of a VSCode debugger launch.json
file:
"port": 10000,
"localSourceRoot": "${workspaceRoot}/vendor/moodle/moodle",
"serverSourceRoot": "/var/www/html/vendor/moodle/moodle"
Inspect the moodleplus_pgdata
Docker volume to determine the mountpoint:
docker volume inspect moodleplus_pgdata
Edit the postgresql.conf
file to set log_statement = 'all'
.
Restart the pgsql
container:
docker-compose restart pgsql
View the logs:
docker-compose logs -f
The below will not remove the pgdata
Docker volume (thereby ensuring the PostgreSQL database is persisted):
docker-compose stop
docker-compose rm -f
The below will remove the pgdata
Docker volume (thereby removing the Moodle database):
. utils/uninit.sh