REDCap External Module Development Guide

Logo

REDCap External Module Development Guide v1.3.1

Authors

Building a REDCap Environment

These instructions describe how to set up a development environment that works on both Mac OSX, Windows, and Linux computers. While this version presents some issues for Windows computers, future versions should address that shortcoming through the use of git-bash.

Setup Checklist for New Developers

This is a short list to get started, links to the required software are presented in the next section

  1. Create a GitHub account
  2. If using Windows, install git-bash
  3. Install GitHub desktop
  4. Configure GitHub desktop for your GitHub account
  5. Install your editor
  6. Configure GitHub desktop to use your editor, and git-bash
  7. Install Docker Desktop
  8. Download and unzip redcap-docker-compose
  9. Set up your REDCap development instance

Required Resources

These tools are recommended for those with no experience in software development, if you already know what you're doing, feel free to substitute your preferred tool where applicable (e.g. a different editor).

REDCap-Specific Setup

VSCodium open folder VSCodium select redcap-docker-compose folder

VSCodium select .env file

TZ=America/Chicago
DOCKER_PREFIX=redcap
WEB_PORT=11033
MYSQL_PORT=21033
PHPMYADMIN_PORT=31033
MAILHOG_PORT=41033

You'll need a terminal that's in the redcap-docker-compose directory to start the Docker containers

terminal nav and docker-compose up -d

Your Docker containers are now downloading required software and initializing. This step will take some time, especially on the first run.

REDCap Docker-Compose Installer

Successful installation

It didn't work!

Sometimes things are weird, and you'll have to rebuild from scratch. To do that, you'll need to open a terminal to the redcap-docker-compose folder and issue these commands:

# Preserve your modules folder because it might have stuff worth preserving
cp -r www/modules .

# The installer will get confused if any part of your old installation exists
rm -rf www
rm -rf logs

# You have to be in the right folder for docker-compose to find its config files
cd rdc

# Destroy the containers and their volumes
docker-compose down -v

# Rebuild the containers and volumes from scratch
docker-compose up -d

If it fails again, you'll need to dig deeper to find out why. It's probably just a small thing, but knowing which small thing is hard to anticipate. Sorry about that.

After setup

Now that you have a working local instance of REDCap, you'll want to get familiar with the tools available to a REDCap administrator in EMD-102: A Tour Through REDCap as an Admin before moving on to the training exercises in REDCap External Module Development for Developers.

Add an extension to VS Code

VSCode can show you syntax errors as you type them if you add an extension. Add the PHP Intellisense extension to VS Code to get this functionality. On Mac access Code > Preferences > Extensions and type "PHP". You'll see PHP Intellisense in the list. Install it.

Open some PHP code, delete a semicolon or a comma and watch for the wiggly red lines under the text. Hover on one next to the text you just changed and consider what the editor is telling you.

Footnotes

Footnotes

These instructions were adapted from a REDCap Development Class presented at the University of Arkansas Medical School in February 2020. The original document is located here.