How to set up a local development environment to run and modify the plugin.
The development environment is set up at https://wp.local/
Unless specified, all commands below should be run from the top-level directory of the plugin source code repository.
- git
- bash
- Docker and Docker Compose
- mkcert (see below)
Although it should be possible to use HTTP in most cases, we do the extra work for HTTPS in order to avoid special cases with third party systems and OIDC Identity Providers.
If you are using a Mac with Homebrew, install mkcert by running
brew install mkcert nssOtherwise, refer to the mkcert documentation for how to install mkcert on your platform.
mkdir scratch/certs
pushd scratch/certs
mkcert -cert-file wp.local.crt -key-file wp.local.key wp.local
mkcert -install
popdAdd wp.local to your hosts file so the name can be used in URLs:
echo "127.0.0.1 wp.local" | sudo tee -a /etc/hostsecho "DB_NAME='wordpress'" > .env
echo "DB_ROOT_PASSWORD='$(openssl rand -base64 24 | cut -c 1-32)'" >> .env
docker-compose up
run-wp core install \
--url=https://wp.local \
--title="Local WordPress Test" \
--skip-email \
--admin_user=admin \
--admin_email="YOU@example.com" # replace with your email addressCOPY AND SAVE THE ADMIN PASSWORD from the output of the wp core install command above, you will need to use it often.
Turn on debug logging.
run-wp config set WP_DEBUG true --raw
run-wp config set WP_DEBUG_DISPLAY true --raw
run-wp config set SCRIPT_DEBUG true --raw
run-wp config set WP_DEBUG_LOG /tmp/wp-debug.logOther configuration:
run-wp rewrite structure '/%postname%/'
run-wp plugin delete akismet hello
run-wp plugin install wp-native-php-sessions --activateBUILD THE PLUGIN BY FOLLOWING THE INSTRUCTIONS IN docs/building.md.
Then,
run-wp plugin activate umich-oidc-loginWatch for errors using
tail -f scratch/logs/wordpress/wp-debug.logcheck-codeIf you get the following error
Error while loading rules from rules directory - ENOENT: no such file or directory, scandir '/home/node/app/node_modules/npm-package-json-lint/src/rules'
then run
pushd node_modules/npm-package-json-lint/src
cp -a rules rules-dir
sed -i -e "s/'rules'/'rules-dir'/" Rules.js
popdThis currently uses NodeJS 14.x installed on the local system, not from a Docker image.
TOP=$(pwd)
cd umich-oidc-login/includes/admin/wp-react-optionskit
# --hot=true must be last command line option
npx wp-scripts start --host=wp.local --server-type=https \
--server-options-cert="${TOP}/scratch/certs/wp.local.crt" \
--server-options-key="${TOP}/scratch/certs/wp.local.key" \
--live-reload --hot=trueDelete the WordPress database and all WordPress files.
docker-compose down --volumes # deletes the DB data volume
rm -rf scratch/wordpress scratch/composer-php* scratch/logs