Skip to content

Development

Casey edited this page Jun 11, 2022 · 6 revisions

There are multiple different ways to get started working on the code. The primary tool used is both/either Visual Studio Code and Docker (and Docker Compose, which needs installing separately on Linux) for local machine development, or GitPod for cloud development.

Methods

Easy Cloud Development

Open in Gitpod

The project GitPod script is designed to set you up with a LAMP stack, complete with fully installed WordPress ready to go for edits. All contained within the GitPod platform.

Devcontainer & GitHub CodeSpaces

I'm in the process of adding a devcontainer setup to the project. In the develop branch, you currently need to change the URL in :8082 DB client to localhost - a solution is being worked on.

If you use either GitHub Codespaces or VS Code Containers extension, you should receive the same setup. Codespaces are still currently in closed beta, and requires being approved on a waitlist. Containers extension for local VS Code is open to all.

Local Development with Docker

Pretty much the same as above - just open a terminal in the root of the project and run docker-compose up --build -d. Bear in mind you'll also need to run Composer.

Explanation

The repository is kitted out with a Docker Compose script that will set you up with a local server architecture designed perfectly for running WordPress. Also comes with essential tools for developing with Simple SMTP, such as an email catcher.

You'll need to install Composer dependencies within the project. You can achieve this by doing either of the following:

  • PHP installed? composer install
  • No PHP? docker run --rm --interactive --tty --volume $PWD:/app composer install --ignore-platform-reqs

To startup the environment, run from the project root: docker-compose up!

You'll have the following:

Tool URL
WordPress http://localhost:8080/
MailHog http://localhost:8081/
phpMyAdmin http://localhost:8082/

(URLs may differ depending on dev method used).

You can also speedline the WordPress installation process with the quickstart script, by running:

docker-compose exec www quickstart

This will skip the WordPress install, with your access being admin and password. There are some further actions you can achieve, to understand those please see the Docker segment of the repository.

Code Quality

The code in this repository is validated using the WordPress Coding Standard. This is automatically installed with Composer dependencies if you install developer dependencies (on by default, you'd have intentionally chosen not to install it). You can run this by doing the following:

php vendor/bin/phpcs .

You may wish to verify you are following WordPress-specific PHPCS rulesets. You can do this by running php vendor/bin/phpcs -i and seeing if WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress comes up.

Unit Testing

This program uses PHPUnit to help run small tests across common aspects of the program. This helps to keep things in check when making changes, and avoid the old dilemma of a change breaking another part of the system you didn't anticpate. It's not fool-proof, but helps to keep the system in check nonetheless.

Before you can run this, ensure you have a mailserver running and that you have a valid .env file with the relevant configurations in place. Otherwise, the SMTP test portion will fail.

This can be run by doing the following:

php vendor/bin/phpunit

Styling (CSS) Changes

This project uses Sass to keep the styling code clean and maintainable. You will need to install a Sass compiler to make changes to the styling (SCSS - sass folder).

sass sass/simple-smtp.scss assets/simple-smtp.css --style=compressed --watch

This only needs to be run if you plan on making adjustments to the CSS.