block-scaffolding-wp
block-scaffolding-wp copied to clipboard
WordPress plugin template for extending Gutenberg
Block Scaffolding for WordPress
Requirements
- WordPress 5.0+ or the Gutenberg Plugin.
- PHP 7.2 or later, Composer and Node.js for dependency management.
- Docker or Vagrant with VirtualBox for a local development environment.
We suggest using a software package manager for installing the development dependencies such as Homebrew on MacOS:
brew install php composer node docker docker-compose
or Chocolatey for Windows:
choco install php composer node nodejs docker-compose
Development
-
Clone the plugin repository.
-
Setup the development environment and tools using Node.js and Composer:
npm installNote that both Node.js and PHP 7.2 or later are required on your computer for running the
npmscripts. Usenpm run docker -- npm installto run the installer inside a Docker container if you don't have the required version of PHP installed locally.
Development Environment
This repository includes a WordPress development environment based on Docker that can be run on your computer or inside a Vagrant and VirtualBox wrapper for network isolation and simple .local domain names.
Using Vagrant
To use the Vagrant based environment, run:
vagrant up
which will make it available at block-scaffolding-wp.local.
Use the included wrapper command for running scripts inside the Docker container running inside Vagrant:
npm run vagrant -- npm run test:php
where npm run test:php is any of the scripts you would like to run.
Visit block-scaffolding-wp.local:8025 to check all emails sent by WordPress.
Using Native Docker
To use the Docker based environment with the Docker engine running on your host, run:
docker-compose up -d
which will make it available at localhost. Ensure that no other Docker containers or services are using port 80 on your machine.
Use the included wrapper command for running scripts inside the Docker container:
npm run docker -- npm run test:php
where npm run test:php is any of the scripts you would like to run.
Visit localhost:8025 to check all emails sent by WordPress.
Scripts
We use npm as the canonical task runner for the project. Some of the PHP related scripts are defined in composer.json.
All of these commands can be run inside the Docker or Vagrant environments by prefixing the scripts with npm run docker -- for Docker or with npm run vagrant -- for Vagrant.
-
npm run buildto build the plugin JS and CSS assets. Usenpm run devto watch and re-build as you work. -
npm run lintto lint both PHP and JS files. Usenpm run lint:jsandnpm run lint:phpto lint JS and PHP seperately. -
npm run testto run both PHP and JS tests without coverage reporting. Usenpm run test:jsandnpm run test:phpto run tests for JS and PHP seperately. -
npm run test-with-coverageto run both PHP and JS tests with coverage reporting.
Continuous Integration
We use Travis CI to lint all code, run tests and report test coverage to Coveralls as defined in .travis.yml.