A submodule installation of WordPress including the WordPress testing suite, linting, formatting, and wp-cli
Since this project has a submodule (WordPress) you need to clone recursively:
git clone [email protected]:invokemedia/wordpress-starter.git --recursive
You can use the provided Dockerfile or use docker-compose
to run the application. The image being used is called webdevops/php-nginx.
To use the Dockerfile to build, you need to run the following commands:
docker build -t my-tag-name .
docker run --net=host -p 80:80 -p 3306:3306 my-tag-name:latest
The --net=host
flag is required, as it allows us to use the host MySQL database.
If you are using docker in any fashion, you will need to set the wp-config.php
DB_HOST
to dockerhost
.
This project works with Laravel Valet if you have the WordpressSubDirectoryValetDriver installed.
You can also use the included .htaccess
file as long as you update it with the correct information for local development.
You will need to setup and configure the following files:
wp-config-sample.php
towp-config.php
wp-tests-config-sample.php
towp-tests-config.php
- Fill out the empty strings that need values
- Run
composer install
Note: Be sure to put different details in wp-tests-config.php
as it will write to that database as part of the testing. You can use the same database for testing, but it adds new tables with a prefix of wptests_
to the database.
If you are using docker in any fashion, you will need to set the wp-config.php
DB_HOST
to dockerhost
.
Be sure to update the apache .htaccess file with your domain to the requests to WordPress are rewritten correctly.
You will need to add the conf/nginx/nginx-site.conf
block of code to your sites virtual host file.
We include some dev packages by default for testing, formatting, and linting code. We also include wp-cli which is installed via composer as well.
One of the additional packages is invokemedia/laravel-helpers which we use to complete some of the missing array_*
methods in PHP. These functions help us write more concise code and reduce repeating blocks of code. This is expecially important when working with arrays of Post
objects.
There are no plugins included but we recommend installing the invokemedia/invoke-helpers as a must-use plugin. It wraps up some of the base WordPress functions in nicer abstractions.
The composer setup includes some commands that can be run manually or also run after an update:
composer run test
: runs the phpunit testscomposer run sniff
: runs phpcs command on the themecomposer run lint
: runs php linting on the theme codecomposer run mess
: runs phpmd on the theme codecomposer run all
: runs test, sniff, and lint together
The wp-cli command is installed via composer. You can access the command as ./vendor/bin/wp
.
Just run phpunit
from the root of the project.