This repository is a start state for a Composer-based WordPress workflow with Pantheon. It is meant to be copied by the the Terminus Build Tools Plugin which will set up for you a brand new
For more background information on this style of workflow, see the Pantheon documentation.
Before running the terminus build:project:create
command, make sure you have all of the prerequisites:
You may find it easier to export the GitHub and CircleCI tokens as variables on your command line where the Build Tools Plugin can detect them automatically:
export GITHUB_TOKEN=[REDACTED]
export CIRCLE_TOKEN=[REDACTED]
Once you have all of the prerequisites in place, you can create your copy of this repo with one command:
terminus build:project:create pantheon-systems/example-wordpress-composer my-new-site --team="Agency Org Name"
The parameters shown here are:
pantheon-systems/example-wordpress-composer
. If you are interest in other source repos like Drupal 8, see the Terminus Build Tools Plugin.my-new-site
to something meaningful for you.--team
flag is optional and refers to a Pantheon organization. Pantheon organizations are often web development agencies or Universities. Setting this parameter causes the newly created site to go within the given organization. Run the Terminus command terminus org:list
to see the organizations you are a member of. There might not be any.You will need PHP 7.0 or higher locally to run the build:project:create
command as some of the dependencies in this project require it. Both composer.json
and pantheon.yml
are currently set to use PHP 7.0.
/web
Pantheon will serve the site from the /web
subdirectory due to the configuration in pantheon.yml
, facilitating a Composer based workflow. Having your website in this subdirectory also allows for tests, scripts, and other files related to your project to be stored in your repo without polluting your web document root.
/web/wp
Even within the /web
directory you may notice that other directories and files are in different places compared to a default WordPress installation. See /web/wp-config.php
for key settings like WP_SITEURL
which allows WordPress core to be relocated to /web/wp
. The overall layout of directories in the repo is inspired by Bedrock.
composer.json
If you are just browsing this repository on GitHub, you may not see some of the directories mentioned above like wp-admin
. That is because WordPress core and its plugins are installed via Composer and ignored in the .gitignore
file. Specific plugins are added to the project via composer.json
and composer.lock
keeps track of the exact version of each plugin (or other dependency). Generic Composer dependencies (not WordPress plugins or themes) are downloaded to the /vendor
folder. Use the require
section for any dependencies you wish to push to Pantheon, even those that might only be used on non-Live environments. Dependencies added in require-dev
such as php_codesniffer
or phpunit
will not be pushed to Pantheon by the CI scripts.
So that CircleCI will have some test to run, this repository includes a configuration of WordHat, A WordPress Behat extension. You can add your own .feature
files within /tests/behat/features
. A fuller guide on WordPress testing with Behat is forthcoming.
To get started using Lando to develop locally complete these one-time steps. Please note than Lando is an independent product and is not supported by Pantheon. For further assistance please refer to the Lando documentation.
lando init
and follow the prompts, choosing the Pantheon recipe followed by entering a valid machine token and selecting the Pantheon site created by [the Terminus build tools plugin].(https://github.com/pantheon-systems/terminus-build-tools-plugin).lando start
to start Lando.
https://<PROJECT_NAME>.lndo.site
.lando composer install --no-ansi --no-interaction --optimize-autoloader --no-progress
to download dependencieslando pull --code=none
to download the media files and database from Pantheon.You should now be able to edit your site locally. The steps above do not need to be completed on subsequent starts. You can stop Lando with lando stop
and start it again with lando start
.
Warning: do NOT push/pull code between Lando and Pantheon directly. All code should be pushed to GitHub and deployed to Pantheon through a continuous integration service, such as CircleCI.
Composer, Terminus and wp-cli commands should be run in Lando rather than on the host machine. This is done by prefixing the desired command with lando
. For example, after a change to composer.json
run lando composer update
rather than composer update
.
We're not using behat for testing - I couldn't get that to work. Check out the /features directory for cucumber tests.
bundle exec cucumber SITE=ci-jenkins-pantheon-wordpress.pantheonsite.io STAGE=dev HTTPS=1 HEADLESS=1
When a pull request is put into GitHub, the Jenkins job kicks off, creates a Pantheon multi-dev with the new PR code, runs the cucumber tests against it. If they succeed, the multidev is deleted, but the code is saved in a git branch by Pantheon. When the pull request in merged in GitHub (now a manual process), another Jenkins job gets kicked off, and if THAT one succeeds, Pantheon merges the changes for the multidev into dev. At this point, you can work with the dev branch as you normally would (Lando etc.).
Also, each multi-dev is created based on the current dev branch, so your dev code and database updates are included.
Notes about the Pull Requests:
The Jenkins job is https://awsjenkins.library.cornell.edu/job/ci-jenkins-pantheon-wordpress/
The multidev sites in Pantheon are named ci-1, ci-2, ci-3, etc.
Creating a new site with this upstream:
# Ignore directories generated by Composer
to just above
# Add directories containing build assets below.
terminus secrets:set [site].[dev,test,live] SMTP_PW [redacted]
v1.3.0
) in cul-it/wp-cul-theme-culu{
"name": "cul-it/advanced-custom-fields-pro",
"description": "WordPress plugin for Unified Library Website",
"type": "wordpress-plugin",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"composer/installers": "^1.0"
}
}